try5
This commit is contained in:
parent
bc5718ddb3
commit
e9715b4a42
10
a1/program.c
10
a1/program.c
@ -70,7 +70,7 @@ int main() {
|
|||||||
} else {
|
} else {
|
||||||
char stack[MAX_SIZE];
|
char stack[MAX_SIZE];
|
||||||
int top = -1;
|
int top = -1;
|
||||||
for (int i = 0; i < err ; i++) {
|
for (int i = 0; i < strlen(input) ; i++) {
|
||||||
char c = input[i];
|
char c = input[i];
|
||||||
if (c == '(' || c == '[' || c == '{' || c == '<') {
|
if (c == '(' || c == '[' || c == '{' || c == '<') {
|
||||||
stack[++top] = 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]));
|
printf("Crossed bracket %c in %d, expected %c\n", c, err-1, getExpectedClosing(stack[top]));
|
||||||
}
|
}
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
printf("Error reading input\n");
|
printf("Error reading input\n");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user