-
Notifications
You must be signed in to change notification settings - Fork 0
/
pacman14.c
43 lines (34 loc) · 973 Bytes
/
pacman14.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
#include <stdio.h>
#include <stdlib.h>
int main() {
int n, t = 0, maior= 0;
scanf("%d",&n);
char **matriz = (char**) malloc(sizeof(char*)*n);
for (int i = 0; i < n; i++) {
setbuf(stdin,NULL);
matriz[i] = (char*) malloc(sizeof(char)*n+1);
scanf("%s",matriz[i]);
}
for (int i = 0; i < n; i++) {
if(i % 2)
for (int j = n-1; j >= 0; j--) {
if(matriz[i][j] == 'o') t++;
if(matriz[i][j] == 'A') {
if(t > maior) maior = t;
t = 0;
}
}
else
for (int j = 0; j < n; j++) {
if(matriz[i][j] == 'o') t++;
if(matriz[i][j] == 'A') {
if(t > maior) maior = t;
t = 0;
}
}
free(matriz[i]);
}
free(matriz);
if(t > maior) maior = t;
printf("%d\n",maior);
}