.


...
Last edited on
brute force works...
if (a+b > c) && (a+c > b) && (b+c > a)

I should make a, b, c into doubles or your triangles will be a bit restricted.

Tests:
min( { a, b, c } ) > 0
and
a + b + c > 2 * max( { a, b, c } )
Looks like the spam bot troll didn't like our reluctance to just write all the code for them for free.
Anyone else report the litte prick? I hope he didn't have enough post whatever to prevent him from getting OUSTED.
The original question was regarding testing whether 3 lengths (a, b ,c) could form a triangle.
1
2
3
4
5
6
7
8
9
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
   double a, b, c;
   cout << "Input a, b, c: ";   cin >> a >> b >> c;
   cout << "This " << ( min( { a, b, c } ) > 0 and a + b + c > 2 * max( { a, b, c } ) ? "is" : "is not" ) << " a triangle\n";
}
The spam bot troll has been around long enough, with enough posts, that reporting the troll does nothing other than simply red flag his trolling.
Well, that little son-of-a-Bob-Wiley...
Topic archived. No new replies allowed.