URI Online Judge | 1035 Selection Test (Solution)
Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1035
Solution:
https://www.urionlinejudge.com.br/judge/en/problems/view/1035
URI Online Judge | 1035
Selection Test 1
Adapted by Neilor Tonin, URI Brazil
Timelimit: 1
Read 4 integer numbers 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.
Sample Input | Sample Output |
5 6 7 8 | Valores nao aceitos |
2 3 2 6 | Valores aceitos |
#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&&d)>=0&&a%2==0)
{
printf
(
"Valores aceitos\n"
);
}
else
printf
(
"Valores nao aceitos\n"
);
return
0;
}
plz tell me what is the problem of thid code
ReplyDelete#include
using namespace std;
int main()
{ int a,b,c,d,sum1,sum2;
cin>>a>>b>>c>>d;
sum1=c+d;
sum2=a+b;
if(b>c){
if(d>a){
if(sum1>sum2){
if(c>0&&d>0){
if(a%2==0){
cout<<"Valores aceitos\n";
}
}
}
}
}
else{
cout<<"Valores nao aceitos\n";
}
return 0;
}
This comment has been removed by the author.
ReplyDelete#include
ReplyDeleteusing namespace std;
int main()
{
int A,B,C,D;
cin>>A>>B>>C>>D;
if(B>C && D>A)
{
if(C+D > A+B)
{
if(C>0 && D>0)
{
if(A%2==0)
{
cout<<"Valores aceitos"<<endl;
}
else
{
cout<<endl;
}
}
else
{
cout<<endl;
}
}
else
{
cout<<endl;
}
}
else
{
cout<<"Valores nao aceitos"<<endl;
}
return 0;
}
why my code is got wrong answer 20%
#include
ReplyDeleteusing namespace std;
int main() {
int a, b, c, d, sum;
cin >> a >> b >> c >> d;
if ((b > c) && (d > a) && ((c + d > a + b)) && (c&&d > 0) && (a % 2 == 0))
cout << "Valores aceitos" << endl;
else
cout << "Valores nao aceitos" << endl;
return 0;
}
this is the correct code
Delete