Update a1/program.c

This commit is contained in:
Yurii Yakovenko 2024-10-25 20:27:36 +00:00
parent a345b708e9
commit 0dbe25d7ae

View File

@ -57,13 +57,14 @@ int main()
mystack.size=0; mystack.size=0;
char str[128]; char str[128];
scanf("%s", str);
fgets(str,100,stdin);
printf("Read: %s", str); printf("Read: %s", str);
int i=0; int i=0;
char c, cs; char c, cs;
bool is_ok=true; bool is_ok=true;
while(str[i]!='\0' && is_ok) while(str[i]!='\0' && str[i]!='\n' && is_ok)
{ {
c=str[i]; c=str[i];
if(c=='<'||c=='('||c=='{'||c=='[') if(c=='<'||c=='('||c=='{'||c=='[')
@ -108,7 +109,7 @@ int main()
} }
i++; i++;
} }
if(count_stack(&mystack)>0) if(count_stack(&mystack)>0)
{ {
cs=pop_stack(&mystack); cs=pop_stack(&mystack);
@ -118,6 +119,7 @@ int main()
printf("\nAll brackets OK\n"); printf("\nAll brackets OK\n");
return 0; return 0;
} }