Selection Test 1 beeCrowd 1035 URI 1035 Solution C Python programming coding solution solved easy solution Read 4 integers and validate them with some
Selection Test 1
Read 4 integers and validate them with some conditions. After this, print if they are valid or not.
The formula is:
- Take input.
- Check If b>c and d>a and c+d>a+b and c>0 and d>0 and a%2==0(If a is even) then print "Valores aceitos"
- If any of these conditions are not true then print "Valores nao aceitos"
- DON'T FORGET TO PUT NEWLINE CHARACTER(\n) AT THE END OF THE LINE EVERY TIME YOU PRINT SOMETHING. ELSE YOU WILL GET A PRESENTATION ERROR.
The solution in C:
#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;
}
The solution in Python:
a,b,c,d=map(int, input().split())
if b>c and d>a and c+d>a+b and c>0 and d>0 and a%2==0:
print("Valores aceitos")
else:
print("Valores nao aceitos")
COMMENTS