From 51325b71d555b0ae30b5bc71476e49fb5ac5607d Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Fri, 25 Oct 2024 19:59:56 +0000 Subject: [PATCH] Update a1/program.c --- a1/program.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/a1/program.c b/a1/program.c index b2980fe..27d925d 100644 --- a/a1/program.c +++ b/a1/program.c @@ -1,8 +1,8 @@ #include #include #include -#include -//// @ +#include + #define STACK_SIZE 200 struct Stack @@ -62,7 +62,8 @@ int main() int i=0; char c, cs; - while(str[i]!='\0') + bool is_ok=true; + while(str[i]!='\0' && is_ok) { c=str[i]; if(c=='<'||c=='('||c=='{'||c=='[') @@ -77,32 +78,34 @@ int main() else { printf("fghfghfgghfghfggh"); - break; + is_ok=false; } if(cs!='<') { printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); - break; + is_ok=false; } if(cs!='(') { printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); - break; + is_ok=false; } if(cs!='(') { printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); - break; + is_ok=false; } if(cs!='{') { printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); - break; + is_ok=false; } } i++; } + if(is_ok) + printf("All bracket OK"); //Crossed bracket > in 12, expected )