lucky four codechef code example
Example 1: lucky four codechef
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t,number,count,rem;
std::cin >> t;
for (int i = 0; i < t; i++) {
cin >> number;
while(number != 0){
rem = number % 10;
if (rem == 4){
count++;
}
number /= 10;
}
std::cout << count << std::endl;
count = 0;
}
return 0;
}
Example 2: Lucky four codechef solution
t=int(input())
a=str(4)
for i in range(t):
x=str(input())
count=0
for j in x:
if j==a:
count=count+1
print(count)