From c3c2e52c686e54214406641d431b30ac6d5646d4 Mon Sep 17 00:00:00 2001 From: Viktor Daniv Date: Sat, 26 Oct 2024 19:50:02 +0000 Subject: [PATCH] Update a1/program.c --- a1/program.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/a1/program.c b/a1/program.c index 6f1dffb..b712df4 100644 --- a/a1/program.c +++ b/a1/program.c @@ -35,13 +35,13 @@ void check_brackets(const char *code) { // Якщо закрита дужка else if (c == ')' || c == '}' || c == ']' || c == '>') { if (stack_top < 0) { - printf("Unexpected closing bracket %c in %d\n", c, i); + printf("Unexpected closing bracket %c at position %d\n", c, i); return; } char top = stack[stack_top--]; char expected = expected_close(top); if (expected != c) { - printf("Crossed bracket %c in %d, expected %c\n", c, i, expected); + printf("Crossed bracket %c at position %d, expected %c\n", c, i, expected); return; } } @@ -49,7 +49,11 @@ void check_brackets(const char *code) { // Перевірка, чи всі дужки закриті if (stack_top >= 0) { - printf("Missing closing brackets: %c\n", expected_close(stack[stack_top])); + printf("Missing closing brackets: "); + while (stack_top >= 0) { + printf("%c", expected_close(stack[stack_top--])); + } + printf("\n"); } else { printf("All brackets OK\n"); } @@ -67,4 +71,4 @@ int main() { check_brackets(code); return 0; -} +} \ No newline at end of file