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