Update a1/program.c

This commit is contained in:
Viktor Daniv 2024-10-26 19:52:11 +00:00
parent 18dec4857d
commit f0493d90a8

View File

@ -27,7 +27,7 @@ void check_brackets(const char *code) {
// Якщо відкрита дужка, додаємо її до стеку // Якщо відкрита дужка, додаємо її до стеку
if (c == '(' || c == '{' || c == '[' || c == '<') { if (c == '(' || c == '{' || c == '[' || c == '<') {
if (stack_top >= MAX - 1) { if (stack_top >= MAX - 1) {
printf("Stack overflow at position %d\n", i); printf("Stack overflow in %d\n", i);
return; return;
} }
stack[++stack_top] = c; stack[++stack_top] = c;
@ -41,7 +41,7 @@ void check_brackets(const char *code) {
char top = stack[stack_top--]; char top = stack[stack_top--];
char expected = expected_close(top); char expected = expected_close(top);
if (expected != c) { if (expected != c) {
printf("Crossed bracket %c at position %d, expected %c\n", c, i, expected); printf("Crossed bracket %c in %d, expected %c\n", c, i, expected);
return; return;
} }
} }