a1
This commit is contained in:
parent
7d01f2a2cf
commit
ae36a3dfe9
@ -9,7 +9,8 @@ int main() {
|
||||
char *brackets1 = "}])>";
|
||||
char stack[LINESIZE];
|
||||
int position[LINESIZE];
|
||||
int x = 0;
|
||||
int x = 0;
|
||||
char expected = '\0';
|
||||
fgets(vstup, LINESIZE, stdin);
|
||||
printf("Read: %s", vstup);
|
||||
for (int j = 0; j < strlen(vstup); j++) {
|
||||
@ -20,7 +21,6 @@ int main() {
|
||||
x++;
|
||||
break;
|
||||
} else if (vstup[j] == brackets1[i]) {
|
||||
char expected = '\0';
|
||||
if (stack[x-1] == '{') expected = '}';
|
||||
else if (stack[x-1] == '[') expected = ']';
|
||||
else if (stack[x-1] == '(') expected = ')';
|
||||
@ -43,7 +43,7 @@ int main() {
|
||||
}
|
||||
}
|
||||
if (x > 0) {
|
||||
printf("Missing closing brackets: %c\n", stack[x-1]);
|
||||
printf("Missing closing brackets: %c\n", expected);
|
||||
} else {
|
||||
printf("All brackets OK\n");
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user