#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main (){
int t, i, n, r, count[10];
cin >> t;
while(t--){
cin >> n;
memset (count, 0, sizeof count);
for (i = 1; i <= n; i++ ){
r = i;
while(r > 0) {
count [r % 10]++;
r = r / 10;
}
}
for (i = 0; i < 9; i++ ){
cout << count[i] << " ";
}
cout << count[9] << endl;
}
return 0;
}
#include <cstdio>
#include <cstring>
using namespace std;
int main (){
int t, i, n, r, count[10];
cin >> t;
while(t--){
cin >> n;
memset (count, 0, sizeof count);
for (i = 1; i <= n; i++ ){
r = i;
while(r > 0) {
count [r % 10]++;
r = r / 10;
}
}
for (i = 0; i < 9; i++ ){
cout << count[i] << " ";
}
cout << count[9] << endl;
}
return 0;
}
No comments:
Post a Comment