From 6d31ca1356f9a38ee160eb6448462a26f01754c8 Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Fri, 25 Oct 2024 19:51:03 +0000 Subject: [PATCH] Update a1/program.c --- a1/program.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) 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