/home/toolbox/public_html/solutions/119/11933/b.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 <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2017-01-25
18 * Purpose: fun
19 * Problem: 11933 - Splitting Number
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 /* 3322222222221111111111
27 * 1098765432109876543210987654321
28 * 1010101010101010101010101010101
29 * 5 5 5 5 5 5 5 5
30 * 0101010101010101010101010101010
31 * A A A A A A A
32 */
33 #define A 0x55555555
34 #define B 0xAAAAAAAA
35 unsigned int num;
36
37 void init()
38 {
39 /* FUNCTION init */
40 } /* FUNCTION init */
41
42 void dump()
43 {
44 /* FUNCTION dump */
45 } /* FUNCTION dump */
46
47 int getInput()
48 {
49 /* FUNCTION getInput */
50 int dataReadFlag;
51
52 scanf(" %d ", &num);
53 dataReadFlag = (0 != num);
54 return (dataReadFlag);
55 } /* FUNCTION getInput */
56
57 void process()
58 {
59 /* FUNCTION process */
60 unsigned int a;
61 unsigned int b;
62
63 printf("A %X %u\n", A, A);
64 printf("B %X %u\n", B, B);
65 printf("num %X %u\n", num, num);
66 a = num & A;
67 b = num & B;
68 printf("a %X %u\n", a, a);
69 printf("b %X %u\n", b, b);
70 printf("%u %u\n", a, b);
71 } /* FUNCTION process */
72
73 int main()
74 {
75 /* main */
76 int moreToDo;
77
78 init();
79 moreToDo = getInput();
80 while (moreToDo)
81 {
82 /* while */
83 process();
84 moreToDo = getInput();
85 } /* while */
86
87 return EXIT_SUCCESS;
88 } /* main */
89