fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int T,N;
  4. int Case[10]={};
  5. int main() {
  6. cin>>T;
  7. for(int e=0;e<T;e+=1){
  8. cin>>N;
  9. for(int q=1;q<=N;q=q+1){
  10. int Q=q;
  11. while(Q!=0){
  12. Case[Q%10]+=1;
  13. Q=Q/10;
  14. }
  15. }
  16. for(int q=0;q<=9;q=q+1){
  17. cout<<Case[q]<<" ";
  18. Case[q]=0;
  19. }
  20. cout<<"\n";
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 5304KB
stdin
2
9
13
stdout
0 1 1 1 1 1 1 1 1 1 
1 6 2 2 1 1 1 1 1 1