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
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
int main ( int argc, char *argv[] )
{
int a[10]={0};
int temp = 0;
int i =0;
int num=0;
while(1==scanf("%d",&num)){
memset(a,0,sizeof(a));
for (i = 1; i <= num; i++) {
temp = i;
do {
a[temp%10]++;
temp = temp/10;
} while(temp);
}
for (i = 0; i < 9; i++) {
printf ( "%d ",a[i] ); /* code */
}
printf ( "%d\n", a[i] );
}
return EXIT_SUCCESS;
} /* ---------- end of function main ---------- */

Comments

2016-12-21