50 lines
1021 B
C
50 lines
1021 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
char add(double A, double B, double C,char AC){
|
|
float CC=A+B;
|
|
if(CC==(float)C || A+B==C)return printf("OK\n");
|
|
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");
|
|
}
|
|
|
|
int main()
|
|
{
|
|
char *str;
|
|
str=(char*)malloc(100);
|
|
double a,b,c;
|
|
char ac,el;
|
|
int ind=0;
|
|
for(int i=0;el!='\n';i++){
|
|
el=getchar();
|
|
if(isspace(el)){
|
|
continue;
|
|
}
|
|
str[ind]=el;
|
|
ind++;
|
|
}
|
|
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
|
if(ac=='+')add(a,b,c,ac);
|
|
else if(ac=='-')subtr(a,b,c,ac);
|
|
else if(ac=='*')multi(a,b,c,ac);
|
|
else if(ac=='/')divi(a,b,c,ac);
|
|
else printf("CHYBA\n");
|
|
return 0;
|
|
}
|
|
|
|
|