Изменить 'du4/program.c'
This commit is contained in:
parent
e3c1986ed2
commit
6e04d3556b
@ -3,25 +3,25 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
int call(double A, double B, double C, char AC){
|
||||
int call(float A, float B, float C, char AC){
|
||||
if(AC=='/'&&B==0){
|
||||
return printf("CHYBA\n");;
|
||||
return printf("CHYBA");;
|
||||
}
|
||||
else if(AC=='+'){
|
||||
if(A+B==C)return printf("OK\n");
|
||||
return printf("ZLE\n");
|
||||
if(A+B==C)return printf("OK");
|
||||
return printf("ZLE");
|
||||
}
|
||||
else if(AC=='-'){
|
||||
if(A-B==C)return printf("OK\n");
|
||||
return printf("ZLE\n");
|
||||
if(A-B==C)return printf("OK");
|
||||
return printf("ZLE");
|
||||
}
|
||||
else if(AC=='*'){
|
||||
if(A*B==C)return printf("OK\n");
|
||||
return printf("ZLE\n");
|
||||
if(A*B==C)return printf("OK");
|
||||
return printf("ZLE");
|
||||
}
|
||||
else if(AC=='/'){
|
||||
if(A/B==C)return printf("OK\n");
|
||||
return printf("ZLE\n");
|
||||
if(A/B==C)return printf("OK");
|
||||
return printf("ZLE");
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ int main()
|
||||
|
||||
char *str;
|
||||
str=(char*)malloc(100);
|
||||
double a,b,c;
|
||||
float a,b,c;
|
||||
char ac,el;
|
||||
int ind=0;
|
||||
for(int i=0;el!='\n';i++){
|
||||
@ -42,9 +42,10 @@ for(int i=0;el!='\n';i++){
|
||||
str[ind]=el;
|
||||
ind++;
|
||||
}
|
||||
//3.4␣+␣2.3␣=␣5.7␣
|
||||
//scanf("%s",str);
|
||||
sscanf(str,"%lf%c%lf=%lf ",&a,&ac,&b,&c);
|
||||
//printf("%f %d %f =%f",a,ac,b,c);
|
||||
sscanf(str,"%f%c%f=%f ",&a,&ac,&b,&c);
|
||||
printf("%f %c %f =%f",a,ac,b,c);
|
||||
call(a,b,c,ac);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user