From 0dbe25d7ae9f3c89657a5793a84557e5e9e5d9df Mon Sep 17 00:00:00 2001 From: Yurii Yakovenko Date: Fri, 25 Oct 2024 20:27:36 +0000 Subject: [PATCH] Update a1/program.c --- a1/program.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/a1/program.c b/a1/program.c index 51216ae..dd34e0d 100644 --- a/a1/program.c +++ b/a1/program.c @@ -57,13 +57,14 @@ int main() mystack.size=0; char str[128]; - scanf("%s", str); + + fgets(str,100,stdin); printf("Read: %s", str); int i=0; char c, cs; bool is_ok=true; - while(str[i]!='\0' && is_ok) + while(str[i]!='\0' && str[i]!='\n' && is_ok) { c=str[i]; if(c=='<'||c=='('||c=='{'||c=='[') @@ -108,7 +109,7 @@ int main() } i++; } - + if(count_stack(&mystack)>0) { cs=pop_stack(&mystack); @@ -118,6 +119,7 @@ int main() printf("\nAll brackets OK\n"); + return 0; } \ No newline at end of file