diff --git a/du4/program.c b/du4/program.c index ecc299d..c2352c0 100644 --- a/du4/program.c +++ b/du4/program.c @@ -1,35 +1,15 @@ #include -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"); }