Aktualizovat „du4/program.c“

This commit is contained in:
Artem Horbunov 2020-04-02 14:54:16 +00:00
parent 5929b34110
commit 633c772c61

View File

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