/home/toolbox/public_html/solutions/124/12405/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-03-31
20 * Purpose: fun
21 * Problem: 12405
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28
29 #define MAX_SIZE 103
30 #define DOT '.'
31
32 int numberOfTimes;
33 char field[MAX_SIZE];
34 int plots;
35
36 void init()
37 {
38 /* FUNCTION init */
39 scanf("%d ", &numberOfTimes);
40 } /* FUNCTION init */
41
42 void dump()
43 {
44 /* FUNCTION dump */
45 } /* FUNCTION dump */
46
47 void getInput()
48 {
49 /* FUNCTION getInput */
50 scanf(" %d ", &plots);
51 scanf(" %s ", field);
52 } /* FUNCTION getInput */
53
54 void process()
55 {
56 /* FUNCTION process */
57 int i;
58 int cnt = 0;
59 int prv;
60
61 prv = DOT == field[0];
62 for (i=1; i<plots; i++)
63 {
64 /* for each plot */
65 DEBUG printf("[%c] (prv=%d) (i=%d) (cnt=%d)\n", field[i], prv, i, cnt);
66 if (prv)
67 {
68 /* previous space was a dot -- insert scarecrow */
69 cnt++;
70 i++;
71 prv = FALSE;
72 } /* previous space was a dot -- insert scarecrow */
73 else
74 {
75 /* previous was not a dot, so et previous if thi is a dot */
76 prv = DOT == field[i];
77 } /* previous was not a dot, so et previous if thi is a dot */
78 } /* for each plot */
79 if (prv)
80 {
81 cnt++;
82 }
83 printf("%d\n", cnt);
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