Feb 22, 2019 at 3:28pm UTC
@AbstractionAnon
Thanks! I think this is right in that scenario:
return (a + b > c && a + c > b && b + c > a) ? true : false;
Correct me if im wrong.
Feb 22, 2019 at 4:32pm UTC
return a + b > c && a + c > b && b + c > a && a > 0 && b > 0 && c > 0;
You don't need a ternary operator.
Feb 22, 2019 at 4:47pm UTC
Oh okay! Edited.
This obviously only returns 1 or 0, where would I include "boolalpha" in this case?
Feb 22, 2019 at 4:51pm UTC
wirelesskill wrote:This obviously only returns 1 or 0
No, it returns true or false (as long as the function had basic type bool).
Only when "cout <<"ing to a stream do true or false get written as 1 or 0.
Insert boolalpha into the output stream before the bool variable which you intend to output. Thus, e.g.,
cout << boolalpha << someBoolVariable;
DON'T include boolalpha anywhere in the function. The result is returned as a perfectly respectable bool.
Last edited on Feb 22, 2019 at 4:52pm UTC
Feb 22, 2019 at 4:56pm UTC
@lastchance sorry, yeah, thats what I meant, its printing 0/1 in the output stream.
Thank you for this!
Feb 22, 2019 at 4:58pm UTC
No worries - suddenly you are making very rapid progress! Good stuff!
Feb 22, 2019 at 4:59pm UTC
Hah thanks! I guess. I was just having trouble understanding the process logically in my mind, once that clicked its kind of straight-shooting after that.