/home/toolbox/public_html/solutions/12/1225/a.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /* fprintf(stderr, "functionName: message", varslist); */
16
17 /*
18 * Author: Isaac Traxler
19 * Date: March 1, 2016
20 * Purpose: fun
21 * Problem: 1225 - Counting Digits
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int numberOfTimes;
29 int num;
30 int cnt[10];
31
32 void init()
33 {
34 /* FUNCTION init */
35 scanf("%d ", &numberOfTimes);
36 } /* FUNCTION init */
37
38 void dump()
39 {
40 /* FUNCTION dump */
41 } /* FUNCTION dump */
42
43 void getInput()
44 {
45 /* FUNCTION getInput */
46 scanf(" %d ", &num);
47 cnt[0] = 0;
48 cnt[1] = 0;
49 cnt[2] = 0;
50 cnt[3] = 0;
51 cnt[4] = 0;
52 cnt[5] = 0;
53 cnt[6] = 0;
54 cnt[7] = 0;
55 cnt[8] = 0;
56 cnt[9] = 0;
57 } /* FUNCTION getInput */
58
59 void process()
60 {
61 /* FUNCTION process */
62 int i;
63 int tmp;
64 int d;
65
66 for (i=1; i<=num; i++)
67 {
68 /* for */
69 tmp = i;
70 while (0 < tmp)
71 {
72 /* while */
73 cnt[(tmp % 10)]++;
74 tmp = tmp / 10;
75 } /* while */
76 } /* for */
77
78 printf("%d", cnt[0]);
79 for (i=1; 10>i; i++)
80 {
81 /* show results */
82 printf(" %d", cnt[i]);
83 } /* show results */
84 printf("\n");
85 } /* FUNCTION process */
86
87 int main()
88 {
89 /* main */
90 int i;
91
92 init();
93 for (i=0; i<numberOfTimes; i++)
94 {
95 /* while */
96 getInput();
97 process();
98 } /* while */
99
100 return EXIT_SUCCESS;
101 } /* main */
102
103