Всі умови | Умова: Дано дійсні позитивні числа x, y, z. З'ясувати чи існує трикутник з довжинами сторін x, y, z. Якщо трикутник існує, то визначити - чи є він гострокутним.
(С.А. Абрамов, Г.Г. Гнездилова,Е.Н. Капустина, М.И. Селюн. Задачи по программированию. - Вологда, 2000. - №47)
Розв'язок на С++
#include
#include
#include
using namespace std;
//hutin puilo!
int main(int argc, char **argv)
{
float x, y, z;
cout << "x = " ; cin >> x;
cout << "y = " ; cin >> y;
cout << "z = " ; cin >> z;
if ((x + y > z) && (x + z > y) && (y + z > x)) {
if ((x * x + y * y > z * z) && (x * x + z * z > y * y)
&& (z * z + y * y > x * x)) {
cout << "Triangle je hostrouholnym.";
} else {
cout << "Triangle ne je hostrouholnym.";
}
} else {
cout << "Triangle do not exist and hutip puilo.";
}
//Glory to Ukraine
return 0;
}