URI - BEECROWD - BEE Online Judge Solution 1035 | Selection Test 1 - URI - BEECROWD - BEE 1035 Solution in C,C++,Python
Read 4 integer values A, B, C and D. Then if B is greater than C and D is greater than A and if the sum of C and D is greater than the sum of A and B and if C and D were positives values and if A is even, write the message “Valores aceitos” (Accepted values). Otherwise, write the message “Valores nao aceitos” (Values not accepted).
Input
Four integer numbers A, B, C and D.
Output
Show the corresponding message after the validation of the values.
Input Sample | Output Sample |
5 6 7 8 | Valores nao aceitos |
2 3 2 6 | Valores aceitos |
URI Online Judge Solution 1035 | Selection Test 1 - URI 1035 Solution in C,C++,Python:
#include <stdio.h>
int main()
{
int a, b, c, d;
scanf("%d %d %d %d", &a, &b, &c, &d);
if((b > c) && (d > a) && (c + d > a + b) && c > 0 && d > 0 && (a % 2 == 0))
printf("Valores aceitos\n");
else
printf("Valores nao aceitos\n");
return 0;
}
Thank You!
ReplyDeleteBest URI Online Judge Solution Site...
if((b > c) && (d > a) && (c + d > a + b) && c > 0 && c > 0 && (a % 2 == 0)) . There is a problem at this line, you take c>0 && c>0 , it should be c>0&&d>0 or (c&&d)>0
ReplyDeleteyes ,it's just a typing mistake. Thanks for mentioning. I updated the code,check now.
ReplyDelete