Answers for "Lucky four codechef solution"

0

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)
Posted by: Guest on May-22-2020
0

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;
}
Posted by: Guest on April-06-2021

Python Answers by Framework

Browse Popular Code Answers by Language