-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1068.c
More file actions
31 lines (22 loc) · 675 Bytes
/
1068.c
File metadata and controls
31 lines (22 loc) · 675 Bytes
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
#include <stdio.h>
#include <string.h>
int main() {
char string[1001];
while(fgets(string, 1001, stdin)){
int parenteses = 0, tamanho = 0, fechamentoAntesDeAbertura = 0;
tamanho = strlen(string);
for(int i = 0; i < tamanho; i++){
if(string[i] == '(')
parenteses++;
else if(string[i] == ')'){
if(parenteses <= 0){
fechamentoAntesDeAbertura++;
break;
}
parenteses--;
}
}
(fechamentoAntesDeAbertura > 0 || parenteses > 0)?printf("incorrect\n"):printf("correct\n");
}
return 0;
}