Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- double ax, ay, bx, by, cx, cy, AB, BC, CA, p, square, h1, h2, h3;
- cin >> ax >> ay >> bx >> by >> cx >> cy;
- if (ay <= 0 || by <= 0 || cy <= 0)
- {
- cout << " Triangle is not in the top part";
- return 0;
- }
- AB = sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay));
- BC = sqrt((cx - bx) * (cx - bx) + (cy - by) * (cy - by));
- CA = sqrt((ax - cx) * (ax - cx) + (ay - cy) * (ay - cy));
- p = (AB + BC + CA) / 2;
- square = sqrt(p * (p - AB) * (p - BC) * (p - CA));
- h1 = square * 2 / AB;
- h2 = square * 2 / BC;
- h3 = square * 2 / CA;
- cout << "Min height is " << min(min(h1, h2), h3);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement