Update a1/program.c

This commit is contained in:
Yurii Yakovenko 2024-10-25 19:59:56 +00:00
parent 6d31ca1356
commit 51325b71d5

View File

@ -1,8 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <stdbool.h>
//// @
#define STACK_SIZE 200 #define STACK_SIZE 200
struct Stack struct Stack
@ -62,7 +62,8 @@ int main()
int i=0; int i=0;
char c, cs; char c, cs;
while(str[i]!='\0') bool is_ok=true;
while(str[i]!='\0' && is_ok)
{ {
c=str[i]; c=str[i];
if(c=='<'||c=='('||c=='{'||c=='[') if(c=='<'||c=='('||c=='{'||c=='[')
@ -77,32 +78,34 @@ int main()
else else
{ {
printf("fghfghfgghfghfggh"); printf("fghfghfgghfghfggh");
break; is_ok=false;
} }
if(cs!='<') if(cs!='<')
{ {
printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); printf("Crossed bracket %c in %d, expected %c", c, i, para(c));
break; is_ok=false;
} }
if(cs!='(') if(cs!='(')
{ {
printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); printf("Crossed bracket %c in %d, expected %c", c, i, para(c));
break; is_ok=false;
} }
if(cs!='(') if(cs!='(')
{ {
printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); printf("Crossed bracket %c in %d, expected %c", c, i, para(c));
break; is_ok=false;
} }
if(cs!='{') if(cs!='{')
{ {
printf("Crossed bracket %c in %d, expected %c", c, i, para(c)); printf("Crossed bracket %c in %d, expected %c", c, i, para(c));
break; is_ok=false;
} }
} }
i++; i++;
} }
if(is_ok)
printf("All bracket OK");
//Crossed bracket > in 12, expected ) //Crossed bracket > in 12, expected )