56 lines
1.1 KiB
C
56 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <ctype.h>
|
|
|
|
int call( double A, double B, double C, char AC){
|
|
double cC=(double)C;
|
|
if(AC=='/'&&B==0 || AC==('+'||'-'||'*'||'-')){
|
|
return printf("CHYBA\n");
|
|
}
|
|
else if(AC=='+'){
|
|
if(A+B==C || C==cC)return printf("OK\n");
|
|
return printf("ZLE\n");
|
|
}
|
|
if(AC=='-'){
|
|
if(A-B==C)return printf("OK\n");
|
|
return printf("ZLE\n");
|
|
}
|
|
if(AC=='*'){
|
|
if(A*B==C)return printf("OK\n");
|
|
return printf("ZLE\n");
|
|
}
|
|
if(AC=='/'){
|
|
double Cc=A/B;
|
|
Cc=(int)(Cc*100000);
|
|
Cc=(float)Cc/100000;
|
|
if(Cc==C || A/B==C)return printf("OK\n");
|
|
return printf("ZLE\n");
|
|
}
|
|
return printf("CHYBA\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++;
|
|
}
|
|
//134.5␣/␣6.7␣=␣20.07462686567164
|
|
//scanf("%s",str);
|
|
sscanf(str,"%lF%c%lF=%lF ",&a,&ac,&b,&c);
|
|
//printf("\n%Lf %c %Lf =%Lf ",a,ac,b,c);
|
|
call(a,b,c,ac);
|
|
return 0;
|
|
}
|
|
|