I've been working on some hacker rank tutorials for practice, and I feel so stupid for being stuck on this problem for the past two days.
Here are the instructions:
We have X = 5 ,Y = 7, and Z = 11. We can replace the variables in the statements with these values.
1.) X + Y = Z is false, because 5 + 7 != 11. Hence, the first line should contain 0.
2.) X <= Y <= Z is true, because 5 <= 7 <= 11. Hence the second line should contain 1.
3.) None of 5, 7, or 11 are even, so the third line should contain 0.
4.) 5,7, 11 and are all different, so the fourth line should contain 1.
5.) 5, 7, and 11 can serve as the sides of a triangle with positive area, as the following (to scale) image shows:
http://prntscr.com/sf5ni6
Hence the fifth line should contain 1.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
#include <iostream>
using namespace std;
int main()
{
int x, y, z;
cin >> x >> y >> z;
//give these variables the correct expressions
bool a;
bool b;
bool c;
bool d;
bool e;
a = (x + y == z);
b = (x <= y && y <= z );
c = (x%2 == 0 || y%2 == 0 || z%2 == 0);
d = (x != y && y != z && x != z);
e = (x > 0 && y > 0 && z > 0);
cout << a << '\n';
cout << b << '\n';
cout << c << '\n';
cout << d << '\n';
cout << e << '\n';
}
| |
Here's the code I've written. I pass the current test case and a few others, but I don't pass other test cases. I don't understand what I'm not seeing. I feel like I'm misunderstanding what the fifth line is asking for.
Thank you in advance.