From 2a776ae59b0cc2225c7192b193ae7273d88ba3ea Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 2 Apr 2020 19:03:18 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu4/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4/program.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/du4/program.c b/du4/program.c index 70a1e3d..0bceb04 100644 --- a/du4/program.c +++ b/du4/program.c @@ -41,11 +41,15 @@ int count=0; int eof; for(;eof!=EOF;count++){ eof=0; + int k=0; str=(char*)malloc(100); int ind=0; for(int i=0;eof!='\n';i++){ eof=getchar(); if(eof==EOF) break; + if(!isdigit(eof) && eof!='.' && eof!=' '){ + k++; + } if(eof!=' '){ str[ind]=eof; ind++; @@ -53,6 +57,11 @@ for(;eof!=EOF;count++){ } if(eof==EOF) break; sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c); + free(str); + if(k>3){ + result[count]=3; + continue; + } switch(ac){ case '+': add(a,b,c,ac,result,count); @@ -67,9 +76,8 @@ for(;eof!=EOF;count++){ divi(a,b,c,ac,result,count); break; default: - result[count]=3; + result[count]=3; } - free(str); } count--; for(int j=0;j