64 lines
1.4 KiB
C
64 lines
1.4 KiB
C
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
int main(){
|
|
|
|
char vstup[100];
|
|
float x;
|
|
float y;
|
|
float z;
|
|
char znamienko;
|
|
|
|
while(fgets(vstup, 100, stdin)==NULL || *vstup=='\n'){
|
|
if(sscanf(vstup, "%f %c %f = %f", &x, znamienko ,&y ,&z)!=4){
|
|
printf("CHYBA\n");
|
|
continue;
|
|
}
|
|
if(znamienko == '+'){
|
|
float rozdiel;
|
|
rozdiel=(x+y)-z;
|
|
if(rozdiel>-0.001 && rozdiel<0.001){
|
|
printf("OK\n");
|
|
}
|
|
else{
|
|
printf("ZLE\n");
|
|
}
|
|
}
|
|
else if(znamienko == '-'){
|
|
float rozdiel;
|
|
rozdiel=(x-y)-z;
|
|
if(rozdiel>-0.001 && rozdiel<0.001){
|
|
printf("OK\n");
|
|
}
|
|
else{
|
|
printf("ZLE\n");
|
|
}
|
|
}
|
|
else if(znamienko == '*'){
|
|
float rozdiel;
|
|
rozdiel=(x*y)-z;
|
|
if(rozdiel>-0.001 && rozdiel<0.001){
|
|
printf("OK\n");
|
|
}
|
|
else{
|
|
printf("ZLE\n");
|
|
}
|
|
}
|
|
else if(znamienko == '/'){
|
|
float rozdiel;
|
|
rozdiel=(x/y)-z;
|
|
if(rozdiel>-0.001 && rozdiel<0.001){
|
|
printf("OK\n");
|
|
}
|
|
else{
|
|
printf("ZLE\n");
|
|
}
|
|
}
|
|
else{
|
|
printf("CHYBA\n");
|
|
}
|
|
|
|
}
|
|
|
|
} |