diff --git a/du4/program.c b/du4/program.c index 67e39fb..ad71092 100644 --- a/du4/program.c +++ b/du4/program.c @@ -3,48 +3,83 @@ #include #include -char add(double A, double B, double C,char AC){ - float CC=A+B; - if(CC==(float)C || A+B==C)return printf("OK\n"); - return printf("ZLE\n"); + + + +void add(double a, double b, double c,char ac, int result[],int count){ + float cc=a+b; + if(cc==(float)c || a+b==c) result[count]=1; + else result[count]=2; } -char subtr(double A, double B, double C,char AC){ - if(A-B==C)return printf("OK\n"); - return printf("ZLE\n"); + +double subtr(double a, double b, double c,char ac, int result[],int count){ + if(a-b==c) result[count]=1; + else result[count]=2; } -char multi(double A, double B, double C,char AC){ - if(A*B==C)return printf("OK\n"); - return printf("ZLE\n"); + +double multi(double a, double b, double c,char ac, int result[],int count){ + if(a*b==c) result[count]=1; + else result[count]=2; } -char divi(double A, double B, double C,char AC){ - float CC=A/B; - double Cc=(int)((A/B)*100000); - if(CC==C || A/B==C || Cc==(int)(C*100000))return printf("OK\n"); - return printf("ZLE\n"); + +double divi(double a, double b, double c,char ac, int result[],int count){ + float cc=a/b; + double Cc=(int)((a/b)*100000); + if(Cc==c || a/b==c || cc==(int)(c*100000)) result[count]=1; + else result[count]=2; } + int main() { char *str; -str=(char*)malloc(100); - double a,b,c; -char ac,el; -int ind=0; -for(int i=0;el!='\n';i++){ - el=getchar(); - if(isspace(el)){ - continue; +int *result; +result=(int*)malloc(100); +double a,b,c; +char ac,el=0; +int count=0; +int eof; +for(;eof!=EOF;count++){ + str=(char*)malloc(20); + eof=scanf("%s",str); + int ind=0; + for(int i=0;i