Изменить 'du4/program.c'
This commit is contained in:
parent
cad86a89ca
commit
71f7ae164f
@ -3,7 +3,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
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==('+'||'-'||'*'||'-')){
|
if(AC=='/'&&B==0 || AC==('+'||'-'||'*'||'-')){
|
||||||
return printf("CHYBA\n");
|
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");
|
return printf("ZLE\n");
|
||||||
}
|
}
|
||||||
if(AC=='/'){
|
if(AC=='/'){
|
||||||
long double Cc=A/B;
|
double Cc=A/B;
|
||||||
Cc=(int)(Cc*100000);
|
Cc=(int)(Cc*100000);
|
||||||
Cc=(float)Cc/100000;
|
Cc=(float)Cc/100000;
|
||||||
if(Cc==C || A/B==C)return printf("OK\n");
|
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("ZLE\n");
|
||||||
}
|
}
|
||||||
return printf("CHYBA\n");
|
return printf("CHYBA\n");
|
||||||
@ -34,7 +34,7 @@ int main()
|
|||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
str=(char*)malloc(100);
|
str=(char*)malloc(100);
|
||||||
long double a,b,c;
|
double a,b,c;
|
||||||
char ac,el;
|
char ac,el;
|
||||||
int ind=0;
|
int ind=0;
|
||||||
for(int i=0;el!='\n';i++){
|
for(int i=0;el!='\n';i++){
|
||||||
@ -45,10 +45,10 @@ for(int i=0;el!='\n';i++){
|
|||||||
str[ind]=el;
|
str[ind]=el;
|
||||||
ind++;
|
ind++;
|
||||||
}
|
}
|
||||||
//3␣/␣45␣=␣0.06666↵
|
//134.5␣/␣6.7␣=␣20.07462686567164
|
||||||
//scanf("%s",str);
|
//scanf("%s",str);
|
||||||
sscanf(str,"%Lf%c%Lf=%Lf ",&a,&ac,&b,&c);
|
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
||||||
//printf("\n%f %c %f =%f ",a,ac,b,c);
|
//printf("\n%Lf %c %Lf =%Lf ",a,ac,b,c);
|
||||||
call(a,b,c,ac);
|
call(a,b,c,ac);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user