From ae36a3dfe911c0e602106aae3d2769377584a991 Mon Sep 17 00:00:00 2001 From: Bohdan Kapliuk Date: Sun, 27 Oct 2024 22:53:45 +0200 Subject: [PATCH] a1 --- a1/program.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/a1/program.c b/a1/program.c index 7537fb2..e7daa56 100644 --- a/a1/program.c +++ b/a1/program.c @@ -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"); }