From 71f7ae164f331e80909fad1ece78946bfb335199 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Tue, 31 Mar 2020 18:48:31 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du4/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4/program.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/du4/program.c b/du4/program.c index 3e4da79..328e61b 100644 --- a/du4/program.c +++ b/du4/program.c @@ -3,7 +3,7 @@ #include #include -int call(long double A, long double B, long double C, char AC){ +int call( double A, double B, double C, char AC){ if(AC=='/'&&B==0 || AC==('+'||'-'||'*'||'-')){ return printf("CHYBA\n"); } @@ -20,11 +20,11 @@ int call(long double A, long double B, long double C, char AC){ return printf("ZLE\n"); } if(AC=='/'){ - long double Cc=A/B; + double Cc=A/B; Cc=(int)(Cc*100000); Cc=(float)Cc/100000; if(Cc==C || A/B==C)return printf("OK\n"); -// printf("%Lf",Cc); + printf("\n%f\n%f",Cc,A/B); return printf("ZLE\n"); } return printf("CHYBA\n"); @@ -34,7 +34,7 @@ int main() { char *str; str=(char*)malloc(100); -long double a,b,c; + double a,b,c; char ac,el; int ind=0; for(int i=0;el!='\n';i++){ @@ -45,10 +45,10 @@ for(int i=0;el!='\n';i++){ str[ind]=el; ind++; } -//3␣/␣45␣=␣0.06666↵ +//134.5␣/␣6.7␣=␣20.07462686567164 //scanf("%s",str); -sscanf(str,"%Lf%c%Lf=%Lf ",&a,&ac,&b,&c); -//printf("\n%f %c %f =%f ",a,ac,b,c); +sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c); +//printf("\n%Lf %c %Lf =%Lf ",a,ac,b,c); call(a,b,c,ac); return 0; }