Update a1/program.c
This commit is contained in:
parent
f919aa8983
commit
13ee4c0bfb
28
a1/program.c
28
a1/program.c
@ -83,25 +83,25 @@ int main()
|
|||||||
}
|
}
|
||||||
if(c=='>' && cs!='<')
|
if(c=='>' && cs!='<')
|
||||||
{
|
{
|
||||||
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(c));
|
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(cs));
|
||||||
|
is_ok=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if(c==']' && cs!='[')
|
||||||
|
{
|
||||||
|
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(cs));
|
||||||
is_ok=false;
|
is_ok=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(c==')' && cs!='(')
|
if(c==')' && cs!='(')
|
||||||
{
|
{
|
||||||
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(c));
|
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(cs));
|
||||||
is_ok=false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if(c==')' && cs!='(')
|
|
||||||
{
|
|
||||||
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(c));
|
|
||||||
is_ok=false;
|
is_ok=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(c=='}' && cs!='{')
|
if(c=='}' && cs!='{')
|
||||||
{
|
{
|
||||||
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(c));
|
printf("\nCrossed bracket %c in %d, expected %c", c, i, para(cs));
|
||||||
is_ok=false;
|
is_ok=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -109,9 +109,13 @@ int main()
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_ok)
|
if(count_stack(&mystack)>0)
|
||||||
printf("\nAll brackets OK\n");
|
{
|
||||||
|
cs=pop_stack(&mystack);
|
||||||
|
printf("\nMissing closing brackets: %c\n", para(cs));
|
||||||
|
}
|
||||||
|
else if(is_ok)
|
||||||
|
printf("\nAll bracket OK");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user