This commit is contained in:
Bohdan Kapliuk 2024-10-28 00:14:50 +02:00
parent f44455c266
commit db6299520f

View File

@ -43,11 +43,14 @@ int main() {
} }
} }
if (x > 0) { if (x > 0) {
if (stack[x-1] == '{') expected = '}'; printf("Missing closing brackets: ");
else if (stack[x-1] == '[') expected = ']'; for (int i = 0; i < x; i++) {
else if (stack[x-1] == '(') expected = ')'; if (stack[i] == '{') printf("}");
else if (stack[x-1] == '<') expected = '>'; else if (stack[i] == '[') printf("]");
printf("Missing closing brackets: %c\n", expected); else if (stack[i] == '(') printf(")");
else if (stack[i] == '<') printf(">");
}
printf("\n");
} else { } else {
printf("All brackets OK\n"); printf("All brackets OK\n");
} }