fork download
  1. //
  2. // main.cpp
  3. // hello
  4. //
  5. // Created by Nilay on 20/07/17.
  6. // Copyright © 2017 Nilay. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12.  
  13. using namespace std;
  14.  
  15. int main()
  16. {
  17. int T, N, temp, arr[100], count;
  18. cin >> T;
  19.  
  20. for(int i=0; i<T; i++)
  21. {
  22. count = 0;
  23. cin >> N;
  24. temp = N;
  25. while(temp > 0)
  26. {
  27. if(temp%10 == 4)
  28. count++;
  29. temp = temp/10;
  30. }
  31. arr[i] = count;
  32. }
  33.  
  34. for(int j=0; j<T; j++)
  35. {
  36. cout << arr[j] << endl;
  37. }
  38.  
  39. return 0;
  40.  
  41.  
  42. }
  43.  
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty