pvjc20/du4/program.c

16 lines
503 B
C

#include <stdio.h>
int main(){
char read[1000000];
scanf("%[^\n]", read);
int num1, num2, answer;
char action;
sscanf(read, "%d %c %d %*c %d", &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");
}