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 <assert.h>
#include <stdlib.h>
#include <ctype.h>
//// @
#include <stdbool.h>
#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 )