-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
45 lines (41 loc) · 751 Bytes
/
Copy pathmain.c
File metadata and controls
45 lines (41 loc) · 751 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
int size = 0;
void read(char* str) {
int i = 0;
int ch;
do {
ch = fgetc(stdin);
str[i++] = ch;
size++;
} while(ch != -1);
str[i-1] = '\0';
}
int brackets(const char* string) {
int checker = 0;
for (int i = 0; i < size; ++i) {
if (string[i] == '(') {
checker++;
}
if (string[i] == ')') {
checker--;
}
if (checker < 0) {
return 1;
}
}
if (checker == 0) {
return 0;
}
return 1;
}
int main() {
char str[1000000];
read(str);
int result = brackets(str);
if (result == 0) {
printf("Correct\n");
}
else {
printf("Incorrect\n");
}
}