Advertisement
Sanlover

Untitled

Oct 21st, 2021
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. double ax, ay, bx, by, cx, cy, AB, BC, CA, p, square, h1, h2, h3;
  7. cin >> ax >> ay >> bx >> by >> cx >> cy;
  8.  
  9. if (ay <= 0 || by <= 0 || cy <= 0)
  10. {
  11. cout << " Triangle is not in the top part";
  12. return 0;
  13. }
  14.  
  15. AB = sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
  16. BC = sqrt((cx - bx) * (cx - bx) + (cy - by) * (cy - by));
  17. CA = sqrt((ax - cx) * (ax - cx) + (ay - cy) * (ay - cy));
  18. p = (AB + BC + CA) / 2;
  19. square = sqrt(p * (p - AB) * (p - BC) * (p - CA));
  20. h1 = square * 2 / AB;
  21. h2 = square * 2 / BC;
  22. h3 = square * 2 / CA;
  23.  
  24. cout << "Min height is " << min(min(h1, h2), h3);
  25.  
  26. return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement