pvjc20/du4/program.c

16 lines
503 B
C
Raw Normal View History

2020-04-01 18:52:14 +00:00
#include <stdio.h>
2020-04-02 14:54:16 +00:00
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");
2020-04-01 18:52:14 +00:00
}