-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1_Lab09_1.c
45 lines (35 loc) · 881 Bytes
/
1_Lab09_1.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#8958
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int calculateScore(char* input) {
int score = 0;
int combo = 0;
for (int i = 0; i < strlen(input); i++) {
if (input[i] == 'O') {
combo++;
score += combo;
} else {
combo = 0;
}
}
return score;
}
int main() {
int testCaseCount;
scanf("%d", &testCaseCount);
char** testCases = (char**)malloc(sizeof(char*) * testCaseCount);
for (int i = 0; i < testCaseCount; i++) {
testCases[i] = (char*)malloc(sizeof(char) * 81);
scanf("%s", testCases[i]);
}
for (int i = 0; i < testCaseCount; i++) {
int score = calculateScore(testCases[i]);
printf("%d\n", score);
}
for (int i = 0; i < testCaseCount; i++) {
free(testCases[i]);
}
free(testCases);
return 0;
}