Update a1/program.c

This commit is contained in:
Marat Izmailov 2024-10-24 12:56:04 +00:00
parent 1edb88f9a7
commit 6e8576acf5

View File

@ -46,14 +46,14 @@ int main() {
// Если стек пустой, это ошибка
if (top == -1) {
printf("Read: %s\n", input);
printf("Unexpected closing bracket %c in %d\n", current, position - 1); // Изменено на position - 1
printf("Unexpected closing bracket %c in %d\n", current, position);
return 1;
}
// Если скобки не совпадают, это ошибка
if (!isMatching(stack[top--], current)) {
printf("Read: %s\n", input);
printf("Crossed bracket %c in %d, expected %c.\n", current, position - 1,
printf("Crossed bracket %c in %d, expected %c.\n", current, position,
(current == '}') ? '{' : (current == ']') ? '[' :
(current == ')') ? '(' : '<');
return 1;