pvjc20/du4/program.c

17 lines
507 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 -1;
}
int check = (action == '/') ? num1 / num2 : (action == '*') ? num1 * num2 : (action == '+') ? num1 + num2 : num1 - num2;
printf("%s\n", (check == answer) ? "OK" : "ZLE");
}