/home/toolbox/public_html/solutions/100/10019/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: 2015-03-13
20 * Purpose:
21 * Problem: 10019
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int numberOfTimes;
29 int num;
30
31 void init()
32 {
33 /* FUNCTION init */
34 scanf("%d ", &numberOfTimes);
35 } /* FUNCTION init */
36
37 void dump()
38 {
39 /* FUNCTION dump */
40 } /* FUNCTION dump */
41
42 void getInput()
43 {
44 /* FUNCTION getInput */
45 scanf(" %d ", &num);
46 } /* FUNCTION getInput */
47
48 int countOnes(int num)
49 {
50 /* FUNCTION countOnes */
51 int tmp;
52 int cnt = 0;
53
54 tmp = num;
55 while (0 < tmp)
56 {
57 /* while */
58 cnt = cnt + (tmp % 2);
59 tmp = tmp / 2;
60 } /* while */
61 return cnt;
62 } /* FUNCTION countOnes */
63
64 int hex2ten(int num)
65 {
66 /* FUNCTION hex2ten */
67 int tot = 0;
68 int tmp;
69 int mult = 1;
70
71 tmp = num;
72 while (0 < tmp)
73 {
74 /* while */
75 tot = tot + (mult * (tmp % 10));
76 tmp = tmp / 10;
77 mult = mult * 16;
78 } /* while */
79 return tot;
80 } /* FUNCTION hex2ten */
81
82 void process()
83 {
84 /* FUNCTION process */
85 char buf[100];
86 int b1;
87 int b2;
88
89 b1 = countOnes(num);
90 b2 = countOnes(hex2ten(num));
91 printf("%d %d\n", b1, b2);
92
93 } /* FUNCTION process */
94
95 int main()
96 {
97 /* main */
98 int i;
99
100 init();
101 for (i=0; i<numberOfTimes; i++)
102 {
103 /* while */
104 getInput();
105 process();
106 } /* while */
107
108 return EXIT_SUCCESS;
109 } /* main */
110
111