Advertisement
borsha06

countingd

Mar 19th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string str(int res)
  4. {
  5.     int i,j;
  6.     string s1;
  7.  
  8.     while(res !=0)
  9.     {
  10.  
  11.         j=res%10;
  12.         s1 += j+48;
  13.         res= res/10;
  14.     }
  15.  
  16.     return s1;
  17. }
  18. int main()
  19. {
  20.     int n,i,j,k,res,l,a[10000],cnt[1000000]= {0};
  21.     cin>>n;
  22.     while(n)
  23.     {
  24.         string s1,s2;
  25.         cin>>k;
  26.         s1="";
  27.  
  28.         for(i=1; i<=k; i++)
  29.         {
  30.             s1+=str(i);
  31.         }
  32.  
  33.  
  34.         for(i=0; i<s1.length(); i++)
  35.         {
  36.             cnt[s1[i]-48]++;
  37.             cout<<cnt[s1[i]-48]<<i<<endl;
  38.  
  39.         }
  40.         for(i=0; i<=10; i++)
  41.         {
  42.             // cout<<cnt[s1[i]-48]<<' ';
  43.             //cout<<endl;
  44.         }
  45.  
  46.         n--;
  47.  
  48.     }
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement