2020-03-31 10:25:27 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2020-04-01 09:33:19 +00:00
|
|
|
char add(double A, double B, double C,char AC){
|
2020-04-01 09:40:57 +00:00
|
|
|
float CC=A+B;
|
2020-04-01 09:40:16 +00:00
|
|
|
if(CC==(float)C || A+B==C)return printf("OK\n");
|
2020-04-01 09:33:19 +00:00
|
|
|
return printf("ZLE\n");
|
|
|
|
}
|
|
|
|
char subtr(double A, double B, double C,char AC){
|
|
|
|
if(A-B==C)return printf("OK\n");
|
|
|
|
return printf("ZLE\n");
|
|
|
|
}
|
|
|
|
char multi(double A, double B, double C,char AC){
|
|
|
|
if(A*B==C)return printf("OK\n");
|
|
|
|
return printf("ZLE\n");
|
|
|
|
}
|
|
|
|
char divi(double A, double B, double C,char AC){
|
|
|
|
float CC=A/B;
|
|
|
|
if(CC==C || 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
|
|
|
|
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
|
|
|
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
2020-04-01 09:33:19 +00:00
|
|
|
if(ac=='+')add(a,b,c,ac);
|
|
|
|
if(ac=='-')subtr(a,b,c,ac);
|
|
|
|
if(ac=='*')multi(a,b,c,ac);
|
|
|
|
if(ac=='/')divi(a,b,c,ac);
|
2020-04-01 09:42:53 +00:00
|
|
|
printf("CHYBA\n");
|
2020-03-31 10:25:27 +00:00
|
|
|
return 0;
|
2020-03-31 11:09:47 +00:00
|
|
|
}
|
2020-03-31 18:40:15 +00:00
|
|
|
|
2020-04-01 09:33:19 +00:00
|
|
|
|