diff --git a/a1/program.c b/a1/program.c index 4d9939d..9ccb624 100644 --- a/a1/program.c +++ b/a1/program.c @@ -57,7 +57,7 @@ int main() mystack.size=0; char str[128]; - + fgets(str,100,stdin); if(str[strlen(str)-1]=='\n') { str[strlen(str)-1]='\0';} printf("Read: %s", str); @@ -65,13 +65,13 @@ int main() int i=0; char c, cs; bool is_ok=true; - while(str[i]!='\0' && str[i]!='\n' && is_ok) + while(str[i]!='\0' && is_ok) { c=str[i]; if(c=='<'||c=='('||c=='{'||c=='[') { push_stack(&mystack, c); - + //print_stack(&mystack); } if(c=='>'||c==']'||c=='}'||c==')') { @@ -110,11 +110,16 @@ int main() } i++; } - + if(count_stack(&mystack)>0) { - cs=pop_stack(&mystack); - printf("\nMissing closing brackets: %c\n", para(cs)); + printf("\nMissing closing brackets: "); + do + { + cs=pop_stack(&mystack); + printf("%c", para(cs)); + }while(count_stack(&mystack)>0); + printf("\n"); } else if(is_ok) printf("\nAll brackets OK\n");