|
|
3 3 5 4 1 2 1 3 3 1 |
3 5 4 : RIGHT TRIANGLE WITH AREA 6.00000 UNITS SQUARED 1 2 1 : NOT A TRIANGLE 3 3 1 : TRIANGLE WITH AREA 1.47902 UNITS SQUARED |
if ( (B % 3) == 0 && ( x != y != z))
x != y != z
first evaluates x != y
, to either true or false. Then it will compare either true or false with z. true != z
, or false != z
. true == not zero
, false == zero
. if ( ((B % 3) == 0) && ( x != y && x != z && y != z))
&&
has a higher precedence than ==
. So ( (B % 3) == 0 && ( x != y != z))
, would first actually evaluate this to true or false: 0 && ( x != y != z)
. And it's going to be false no matter what because && needs both sides true to evaluate to true, and 0 is false. Then it would compare false with (b % 3)
. So that whole statement is really equivalent to if ((B % 3) == 0)
.
|
|
3 <- this is the number of x,y & z i want to input 3 5 4 1 2 1 3 3 1 |
3 5 4 : RIGHT TRIANGLE WITH AREA 6.00000 UNITS SQUARED 1 2 1 : NOT A TRIANGLE 3 3 1 : TRIANGLE WITH AREA 1.47902 UNITS SQUARED |
then..after that..i will output the result |
x != y != z
pointed by iseeplusplusArea = sqrt ( s * ( s - x ) * ( s - y ) * ( s - z ));
you may be computing the root of a negative number.iseeplusplus wrote: |
---|
Also, && has a higher precedence than == . |