Witajcie. To mój drugi dzień nauki C++ i robiąc zadanie ze spoja : https://pl.spoj.pl/problems/RODZ_TRO/ natknąłem się na problem
#include <iostream>
using namespace std;
int main()
{
int a, b, c;
int first, second, third;
while(cin >> a >> b >> c)
{
if(a > b && a > c)
if(b > c)
first = a, second = b, third = c;
else
first = a, second = c, third = b;
else if (b > a && b > c)
if(a > c)
first = b, second = a, third = c;
else
first = b, second = c, third = a;
else if(c > a && c > b)
if(a > b)
first = c, second = a, third = b;
else
first = c, second = b, third = a;
else if( c == a && c == b)
first = second = third = a;
else
second = third = 5, first = 6;
if((a+b < c) || (b+c < a) || (c+a < b) )
cout << "brak\n";
else
{
if( (second * second) + ( third * third) == (first * first) )
cout << "prostokatny\n";
if( (second * second) + ( third * third) > (first * first) )
cout << "ostrokatny\n";
if( (second * second) + ( third * third) < (first * first) )
cout << "rozwartokatny\n";
}
}
return 0;
}
Wpisując dane wychodzi mi wszystko jak jest na stronie jednak wyskakuje mi że błędna odpowiedź. Da się te warunki jakoś inaczej zapisać ?
P.S nie uwzględniłem, że podany bok nie może być 0 - czy to może przez to ?