/home/toolbox/public_html/solutions/127/12750/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-09-30
20 * Purpose: fun
21 * Problem: 12750
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int numberOfTimes;
29 int games;
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 ", &games);
46 } /* FUNCTION getInput */
47
48 void process()
49 {
50 /* FUNCTION process */
51 int i;
52 int losses = 0;
53 char score;
54 int keptJob = TRUE;
55
56 for (i=1; i<=games; i++)
57 {
58 /* for each game */
59 scanf(" %c ", &score);
60 DEBUG printf("[%c]", score);
61 if ('W' == score)
62 {
63 losses = 0;
64 }
65 else
66 {
67 losses++;
68 }
69 if (3 == losses)
70 {
71 /* job lost */
72 if (keptJob)
73 {
74 printf("%d\n", i);
75 }
76 keptJob = FALSE;
77 } /* job lost */
78 } /* for each game */
79 if (keptJob)
80 {
81 /* keeps job */
82 printf("Yay! Mighty Rafa persists!\n");
83 } /* keeps job */
84 } /* FUNCTION process */
85
86 int main()
87 {
88 /* main */
89 int i;
90
91 init();
92 for (i=1; i<=numberOfTimes; i++)
93 {
94 /* while */
95 getInput();
96 printf("Case %d: ", i);
97 process();
98 } /* while */
99
100 return EXIT_SUCCESS;
101 } /* main */
102
103