Aktualizovat „du4/program.c“

This commit is contained in:
Artem Horbunov 2020-04-02 16:02:29 +00:00
parent c5b23eecfd
commit 95d9306a48

View File

@ -8,9 +8,10 @@ int main(){
sscanf(read, "%f %c %f %*c %f", &num1, &action, &num2, &answer); sscanf(read, "%f %c %f %*c %f", &num1, &action, &num2, &answer);
if(action != '/' && action != '*' && action != '-' && action != '+'){ if(action != '/' && action != '*' && action != '-' && action != '+'){
printf("CHYBA\n"); printf("CHYBA\n");
return -1; return 0;
} }
float check = (action == '/') ? num1 / num2 : (action == '*') ? num1 * num2 : (action == '+') ? num1 + num2 : num1 - num2; 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"); printf("%s\n", (check == answer) ? "OK" : "ZLE");
} }