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>
int main()
{
int a, b;
scanf("%d%d", &a, &b);
float c;
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 \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;
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");
}