-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathLuckyFour(modified).cpp
More file actions
57 lines (48 loc) · 1.07 KB
/
LuckyFour(modified).cpp
File metadata and controls
57 lines (48 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
Karan likes the number 4 very much.
Impressed by the power of this number, Karan has begun to look for occurrences of four anywhere. He has a list of T integers, for each of them he wants to calculate the number of occurrences of the digit 4 in the decimal representation. He is too busy now, so please help him.
Input
The first line of input consists of a single integer T, denoting the number of integers in Karan's list.
Then, there are T lines, each of them contain a single integer from the list.
Output
Output T lines. Each of these lines should contain the number of occurrences of the digit 4 in the respective integer from Karan's list.
Constraints
1 ≤ T ≤ 10^5
(Subtask 1): 0 ≤ Numbers from the list ≤ 9 - 33 points.
(Subtask 2): 0 ≤ Numbers from the list ≤ 109 - 67 points.
Example
Input:
5
447474
228
6664
40
81
Output:
4
0
1
1
0
*/
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int c=0;
while(n!=0)
{
int d=n%10;
if(d==4)
c++;
n=n/10;
}
cout<<c<<endl;
}
}