Advertisement
Farjana_akter

Untitled

Feb 13th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,t,i,j,k,a1,a0,a2,a3,a4,a5,a6,a7,a8,a9;
  7. string s="";
  8. cin>>t;
  9. while(t--)
  10. {
  11. a0=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0;
  12. cin>>n;
  13. for (i=1; i<=n; i++) {
  14. s+=std::to_string(i);
  15. }
  16. for(k=1;s[k];i++)
  17. {
  18. if(s[k]=='0')
  19. a0++;
  20. else if(s[k]=='1')
  21. a1++;
  22. else if(s[k]=='2')
  23. a2++;
  24. else if(s[k]=='3')
  25. a3++;
  26. else if(s[k]=='4')
  27. a4++;
  28. else if(s[k]=='5')
  29. a5++;
  30. else if(s[k]=='6')
  31. a6++;
  32. else if(s[k]=='7')
  33. a7++;
  34. else if(s[k]=='8')
  35. a8++;
  36. else if(s[k]=='9')
  37. a9++;
  38. }
  39. cout<<a0<<" "<<a1<<" "<<a2<<" "<<a3<<" "<<a4<<" "<<a5<<" "<<a6<<" "<<a7<<" "<<a8<<" "<<a9<<endl;
  40. }
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement