-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp1225.cpp
51 lines (50 loc) · 1.26 KB
/
p1225.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T; cin>>T;
for(int t=1;t<=T;t++)
{
int digits[10]={0};
int N; cin>>N;
string s;
for(int i=1;i<=N;i++)
{
stringstream ss;
ss<<i;
string str=ss.str();
s+=str;
}
for(int i=0;i<s.size();i++)
{
if(s[i]=='0')
digits[0]++;
else if(s[i]=='1')
digits[1]++;
else if(s[i]=='2')
digits[2]++;
else if(s[i]=='3')
digits[3]++;
else if(s[i]=='4')
digits[4]++;
else if(s[i]=='5')
digits[5]++;
else if(s[i]=='6')
digits[6]++;
else if(s[i]=='7')
digits[7]++;
else if(s[i]=='8')
digits[8]++;
else if(s[i]=='9')
digits[9]++;
}
for(int i=0;i<10;i++)
{
cout<<digits[i];
if(i<9)
cout<<" ";
}
cout<<endl;
}
return 0;
}