2020-03-31 10:25:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2020-03-31 11:09:47 +00:00
|
|
|
int call(float A, float B, float C, char AC){
|
2020-03-31 11:30:05 +00:00
|
|
|
if(AC=='/'&&B==0||AC==('+'||'-'||'*'||'-')){
|
|
|
|
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 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:02:27 +00:00
|
|
|
else 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:02:27 +00:00
|
|
|
else 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=='/'){
|
|
|
|
float Cc=A/B;
|
|
|
|
Cc=(int)(Cc*100000);
|
|
|
|
Cc=(float)Cc/100000;
|
|
|
|
if(Cc==C)return printf("OK");
|
|
|
|
printf("%f",Cc);
|
|
|
|
return printf("ZLE");
|
2020-03-31 11:30:05 +00:00
|
|
|
}
|
2020-03-31 11:54:11 +00:00
|
|
|
return printf("CHYBA");
|
2020-03-31 10:25:27 +00:00
|
|
|
}
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
str=(char*)malloc(100);
|
2020-03-31 11:09:47 +00:00
|
|
|
float 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 11:09:47 +00:00
|
|
|
sscanf(str,"%f%c%f=%f ",&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
|
|
|
}
|