/home/toolbox/public_html/solutions/6/621/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: 2020-05-18
20 * Purpose: fun
21 * Problem: 621 - Secret Research
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 #define MAX_LINE 100001
29
30 int numberOfTimes;
31 char num[MAX_LINE];
32
33 void init()
34 {
35 /* FUNCTION init */
36 scanf("%d ", &numberOfTimes);
37 } /* FUNCTION init */
38
39 void dump()
40 {
41 /* FUNCTION dump */
42 } /* FUNCTION dump */
43
44 void getInput()
45 {
46 /* FUNCTION getInput */
47 fgets(num, MAX_LINE, stdin);
48 num[strlen(num)-1] = 0;
49 } /* FUNCTION getInput */
50
51 /***************
52 * + positive result S = 1 or S = 4 or S = 78
53 * - negative result S = S35
54 * * experiment failed S = 9S4
55 * ? experiment not completed S = 190S
56 */
57
58 void process()
59 {
60 /* FUNCTION process */
61 char result = '?';
62 int tmp;
63 tmp = strlen(num) - 1;
64
65 if ((0 == strcmp(num, "1")) ||
66 (0 == strcmp(num, "4")) ||
67 (0 == strcmp(num, "78")))
68 {
69 /* positive */
70 result = '+';
71 } /* positive */
72 else if (('3' == num[tmp - 1]) && ('5' == num[tmp]))
73 {
74 /* negative */
75 result = '-';
76 } /* negative */
77 else if (('9' == num[0]) && ('4' == num[tmp]))
78 {
79 /* failed */
80 result = '*';
81 } /* failed */
82 printf("%c\n", result);
83 } /* FUNCTION process */
84
85 int main()
86 {
87 /* main */
88 int i;
89
90 init();
91 for (i=0; i<numberOfTimes; i++)
92 {
93 /* while */
94 getInput();
95 process();
96 } /* while */
97
98 return EXIT_SUCCESS;
99 } /* main */
100
101