This commit is contained in:
Nataliia Kobryn 2025-10-20 00:19:32 +02:00
parent bc5718ddb3
commit e9715b4a42
2 changed files with 7 additions and 3 deletions

BIN
a1/prog

Binary file not shown.

View File

@ -70,7 +70,7 @@ int main() {
} else {
char stack[MAX_SIZE];
int top = -1;
for (int i = 0; i < err ; i++) {
for (int i = 0; i < strlen(input) ; i++) {
char c = input[i];
if (c == '(' || c == '[' || c == '{' || c == '<') {
stack[++top] = c;
@ -86,8 +86,12 @@ int main() {
printf("Crossed bracket %c in %d, expected %c\n", c, err-1, getExpectedClosing(stack[top]));
}
} else {
printf("Missing closing brackets: %c\n", getExpectedClosing(stack[top]));
}
printf("Missing closing brackets: ");
for (int i = top; i > -1; i--) {
printf("%c", getExpectedClosing(stack[i]));
}
printf("\n");
}
}
} else {
printf("Error reading input\n");