diff --git a/a1/program.c b/a1/program.c index 7c4ff8b..d4cda9d 100644 --- a/a1/program.c +++ b/a1/program.c @@ -27,18 +27,21 @@ int main() { else if (stack[x-1] == '<') expected = '>'; if (vstup[j] != expected) { + if(expected != '\0'){ printf("Crossed bracket %c in %d, expected %c\n", vstup[j], j, expected); return 0; + } + else{ + printf("Unexpected closing bracket %c in %d\n", vstup[j], position[x-1]); + return 0; + } } x--; + expected = '\0'; break; } } } - if (x > 0) { - printf("Unexpected closing bracket %c in %d\n", stack[x-1], position[x-1]); - } else { - printf("All brackets OK\n"); - } + printf("All brackets OK\n"); return 0; } \ No newline at end of file