diff --git a/a1/program.c b/a1/program.c index ad6c78d..b2980fe 100644 --- a/a1/program.c +++ b/a1/program.c @@ -68,16 +68,39 @@ int main() if(c=='<'||c=='('||c=='{'||c=='[') { push_stack(&mystack, c); + print_stack(&mystack); } - if(c=='>') + if(c=='>'||c==']'||c=='}'||c==')') { - cs=pop_stack(&mystack); + if(count_stack(&mystack)>0) + cs=pop_stack(&mystack); + else + { + printf("fghfghfgghfghfggh"); + break; + } if(cs!='<') { - printf("Crossed bracket %c in %d, expected %c", c, i); + printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); + break; + } + if(cs!='(') + { + printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); + break; + } + if(cs!='(') + { + printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); + break; + } + if(cs!='{') + { + printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); + break; } } - + i++; } @@ -85,5 +108,4 @@ int main() return 0; -} - \ No newline at end of file +} \ No newline at end of file