Update a1/program.c

This commit is contained in:
Yurii Yakovenko 2024-10-25 20:36:23 +00:00
parent 0f87961d3c
commit ff87c1ef40

View File

@ -65,13 +65,13 @@ int main()
int i=0;
char c, cs;
bool is_ok=true;
while(str[i]!='\0' && str[i]!='\n' && is_ok)
while(str[i]!='\0' && is_ok)
{
c=str[i];
if(c=='<'||c=='('||c=='{'||c=='[')
{
push_stack(&mystack, c);
//print_stack(&mystack);
}
if(c=='>'||c==']'||c=='}'||c==')')
{
@ -112,9 +112,14 @@ int main()
}
if(count_stack(&mystack)>0)
{
printf("\nMissing closing brackets: ");
do
{
cs=pop_stack(&mystack);
printf("\nMissing closing brackets: %c\n", para(cs));
printf("%c", para(cs));
}while(count_stack(&mystack)>0);
printf("\n");
}
else if(is_ok)
printf("\nAll brackets OK\n");