Advertisement
evage

Untitled

Jan 25th, 2022
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     int a,b,c;
  7.     cout << "Enter triangle's sides\n";
  8.     int ar[3];
  9.     for (int i = 0; i < 3; ++i)
  10.         cin >> ar[i];
  11.     if (ar[0] <= 0 || ar[1] <= 0 || ar[1] <= 0){
  12.         cout << "trinagle does not exist";
  13.         return 0;
  14.     }
  15.  
  16.     a = min(min(ar[0],ar[1]),ar[2]);
  17.     c = max(max(ar[0],ar[1]),ar[2]);
  18.     b = ar[0]+ar[1]+ar[2] - a - c;
  19.     if (cin.fail()) {cout << "enter data again"; return 0;}
  20.     if (a + b < c) {
  21.         cout << "triangle does not exist";
  22.         return 0;
  23.     }
  24.     if (a*a + b*b == c*c)
  25.         cout << "right triangle";
  26.     else
  27.         cout << "not right triangle";
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement