/home/toolbox/public_html/solutions/4/408/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 <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: 2018-08-28
18 * Purpose: fun
19 * Problem: 408 - Uniform Generator
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26
27 int stp;
28 int md;
29
30 /* if stp and md are relatively prime, then they are good choices */
31
32 void init()
33 {
34 /* FUNCTION init */
35 } /* FUNCTION init */
36
37 void dump()
38 {
39 /* FUNCTION dump */
40 } /* FUNCTION dump */
41
42 int getInput()
43 {
44 /* FUNCTION getInput */
45 int dataReadFlag;
46
47 dataReadFlag = (2 == scanf(" %d %d ", &stp, &md));
48 return (dataReadFlag);
49 } /* FUNCTION getInput */
50
51 int gcd(int a, int b)
52 {
53 /* FUNCTION gcd */
54 int ret;
55 if (0 == (a % b))
56 {
57 /* found the end */
58 ret = b;
59 } /* found the end */
60 else
61 {
62 /* need more iterations */
63 ret = gcd(b, (a%b));
64 } /* need more iterations */
65 return ret;
66 } /* FUNCTION gcd */
67
68 void process()
69 {
70 /* FUNCTION process */
71 int tmp;
72
73 tmp = gcd(stp, md);
74 printf("%10d%10d ", stp, md);
75 if (1 != tmp)
76 {
77 printf("Bad");
78 }
79 else
80 {
81 printf("Good");
82 }
83 printf(" Choice\n\n");
84
85 } /* FUNCTION process */
86
87 int main()
88 {
89 /* main */
90 int moreToDo;
91
92 init();
93 moreToDo = getInput();
94 while (moreToDo)
95 {
96 /* while */
97 process();
98 moreToDo = getInput();
99 } /* while */
100
101 return EXIT_SUCCESS;
102 } /* main */
103