From 08b68b2eabfac81d349a58983aa0bb5272c8f590 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 2 Apr 2020 13:21:51 +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 | 97 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 31 deletions(-) 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