lucky four codechef solution

Solutions on MaxInterview for lucky four codechef solution by the best coders in the world

showing results for - "lucky four codechef solution"
Niklas
13 Aug 2016
1t=int(input())
2a=str(4)
3for i in range(t):
4  x=str(input())
5  count=0
6  for j in x:
7    if j==a:
8      count=count+1
9   print(count)
Marceau
06 Jan 2021
1#include <iostream>
2using namespace std;
3
4int main() {
5	// your code goes here
6	int t,number,count,rem;
7	std::cin >> t;
8	
9	for (int i = 0; i < t; i++) {
10	    cin >> number;
11	    while(number != 0){
12	        rem = number % 10;
13	        if (rem == 4){
14	            count++;
15	        }
16	        number /= 10;
17	    }
18	    std::cout << count << std::endl;
19	    count = 0;
20	}
21	return 0;
22}