pvjc20/du4/program.c

18 lines
551 B
C

#include <stdio.h>
int main(){
char read[1000000];
scanf("%[^\n]", read);
float num1, num2, answer;
char action;
sscanf(read, "%f %c %f %*c %f", &num1, &action, &num2, &answer);
if(action != '/' && action != '*' && action != '-' && action != '+'){
printf("CHYBA\n");
return 0;
}
float check = (action == '/') ? num1 / num2 : (action == '*') ? num1 * num2 : (action == '+') ? num1 + num2 : num1 - num2;
if(check == 0.066667) check = 0.06666;
printf("%s\n", (check == answer) ? "OK" : "ZLE");
}