Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     float x1, x2, x3, y1, y2, y3, p, a, b, c, h1, h2, h3;
  9.  
  10.     cout << "Enter coordinates: \n";
  11.     cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  12.  
  13.     a = sqrt(pow((x2-x1),2)+pow((y2-y1),2));
  14.     b = sqrt(pow((x3-x2),2)+pow((y3-y2),2));
  15.     c = sqrt(pow((x1-x3),2)+pow((y1-y3),2));
  16.  
  17.     if (a + b > c && b + c > a && a + c > b)
  18.     {
  19.         if (pow(a, 2) + pow(b, 2) == pow(c, 2) || pow(b,2) + pow (c,2) == pow(a, 2) || pow(a, 2) + pow(c, 2) == pow(b, 2))
  20.             cout << "Right angled triangle";
  21.  
  22.         else if (
  23.                  (pow(a, 2) - pow(b, 2) - pow(c, 2)) / ((-2)*b*c) > 0 &&
  24.                  (pow(b, 2) - pow(c, 2) - pow(a, 2)) / ((-2)*a*c) > 0 &&
  25.                  (pow(c, 2) - pow(a, 2) - pow(b, 2)) / ((-2)*a*b) > 0
  26.                 )
  27.             cout << "Acute-angled triangle\n";
  28.  
  29.         else cout << "Obtuse-angled triangle\n";
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement