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