From db6299520fe056bce010f39350dff9c42e4c16fc Mon Sep 17 00:00:00 2001 From: Bohdan Kapliuk Date: Mon, 28 Oct 2024 00:14:50 +0200 Subject: [PATCH] a1 --- a1/program.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/a1/program.c b/a1/program.c index 5e87a6f..96e0764 100644 --- a/a1/program.c +++ b/a1/program.c @@ -43,11 +43,14 @@ int main() { } } if (x > 0) { - if (stack[x-1] == '{') expected = '}'; - else if (stack[x-1] == '[') expected = ']'; - else if (stack[x-1] == '(') expected = ')'; - else if (stack[x-1] == '<') expected = '>'; - printf("Missing closing brackets: %c\n", expected); + printf("Missing closing brackets: "); + for (int i = 0; i < x; i++) { + if (stack[i] == '{') printf("}"); + else if (stack[i] == '[') printf("]"); + else if (stack[i] == '(') printf(")"); + else if (stack[i] == '<') printf(">"); + } + printf("\n"); } else { printf("All brackets OK\n"); }