2020-03-31 10:25:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2020-03-31 18:48:31 +00:00
|
|
|
int call( double A, double B, double C, char AC){
|
2020-03-31 18:55:32 +00:00
|
|
|
double cC=(double)C;
|
2020-03-31 18:40:15 +00:00
|
|
|
if(AC=='/'&&B==0 || AC==('+'||'-'||'*'||'-')){
|
2020-03-31 11:30:05 +00:00
|
|
|
return printf("CHYBA\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
2020-03-31 11:02:27 +00:00
|
|
|
else if(AC=='+'){
|
2020-03-31 18:55:32 +00:00
|
|
|
if(A+B==C || C==cC)return printf("OK\n");
|
2020-03-31 11:11:50 +00:00
|
|
|
return printf("ZLE\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
if(AC=='-'){
|
2020-03-31 11:11:50 +00:00
|
|
|
if(A-B==C)return printf("OK\n");
|
|
|
|
return printf("ZLE\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
if(AC=='*'){
|
2020-03-31 11:11:50 +00:00
|
|
|
if(A*B==C)return printf("OK\n");
|
|
|
|
return printf("ZLE\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
2020-03-31 11:54:11 +00:00
|
|
|
if(AC=='/'){
|
2020-03-31 18:48:31 +00:00
|
|
|
double Cc=A/B;
|
2020-03-31 11:54:11 +00:00
|
|
|
Cc=(int)(Cc*100000);
|
|
|
|
Cc=(float)Cc/100000;
|
2020-03-31 18:40:15 +00:00
|
|
|
if(Cc==C || A/B==C)return printf("OK\n");
|
2020-03-31 18:48:31 +00:00
|
|
|
printf("\n%f\n%f",Cc,A/B);
|
2020-03-31 11:55:25 +00:00
|
|
|
return printf("ZLE\n");
|
2020-03-31 11:30:05 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
return printf("CHYBA\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
|
2020-03-31 10:25:27 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
str=(char*)malloc(100);
|
2020-03-31 18:48:31 +00:00
|
|
|
double a,b,c;
|
2020-03-31 11:02:27 +00:00
|
|
|
char ac,el;
|
|
|
|
int ind=0;
|
|
|
|
for(int i=0;el!='\n';i++){
|
|
|
|
el=getchar();
|
|
|
|
if(isspace(el)){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
str[ind]=el;
|
|
|
|
ind++;
|
|
|
|
}
|
2020-03-31 18:48:31 +00:00
|
|
|
//134.5␣/␣6.7␣=␣20.07462686567164
|
2020-03-31 18:40:15 +00:00
|
|
|
//scanf("%s",str);
|
2020-03-31 18:48:31 +00:00
|
|
|
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
|
|
|
//printf("\n%Lf %c %Lf =%Lf ",a,ac,b,c);
|
2020-03-31 10:25:27 +00:00
|
|
|
call(a,b,c,ac);
|
|
|
|
return 0;
|
2020-03-31 11:09:47 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
|