/home/toolbox/public_html/solutions/118/11839/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 #include <ctype.h>
10
11 #define TRUE (1 == 1)
12 #define FALSE (1 != 1)
13
14 #define DEBUG if (FALSE)
15
16 /*
17 * Author: Isaac Traxler
18 * Date: 2021-12-5
19 * Purpose: fun
20 * Problem: 11839 - Optical Reader
21 */
22
23 /*
24 * This template reads data until a terminating value is reached.
25 */
26 int cnt;
27 char letters[6] = { "ABCDE"};
28
29 void init()
30 {
31 /* FUNCTION init */
32 } /* FUNCTION init */
33
34 void dump()
35 {
36 /* FUNCTION dump */
37 } /* FUNCTION dump */
38
39 int getInput()
40 {
41 /* FUNCTION getInput */
42 int dataReadFlag;
43 int i;
44
45 scanf(" %d ", &cnt);
46 dataReadFlag = (0 < cnt);
47 return (dataReadFlag);
48 } /* FUNCTION getInput */
49
50 void process()
51 {
52 /* FUNCTION process */
53 int i;
54 int j;
55 int marked;
56 int idx;
57 int tmp;
58
59 for (i=0; cnt>i; i++)
60 {
61 /* get each answer */
62 marked = 0;
63 for (j=0; 5>j; j++)
64 {
65 /* get each response */
66 scanf(" %d ", &tmp);
67 if (128 > tmp)
68 {
69 /* found a marked answer */
70 marked++;
71 idx = j;
72 } /* found a marked answer */
73 } /* get each response */
74 if (1 == marked)
75 {
76 /* one valid mark */
77 printf("%c\n", letters[idx]);
78 } /* one valid mark */
79 else
80 {
81 /* no clear answer */
82 printf("*\n");
83 } /* no clear answer */
84 } /* get each answer */
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