Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- freopen("trianglearea.in","r", stdin);
- freopen("trianglearea.out","w", stdout);
- double x,y,a,b,c,x1,x2,y1,y2,p;
- cin >> x >> y >> x1 >> y1 >> x2 >> y2;
- a = sqrt(((x-x1)*(x-x1))+((y-y1)*(y-y1)));
- b = sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
- c = sqrt(((x2-x)*(x2-x))+((y2-y)*(y2-y)));
- p = (a+b+c)/2;
- if ((a+b<=c)||(c+b<=a)||(c+a<=b)) cout << -1;
- else {
- p = sqrt(p*(p-a)*(p-b)*(p-c));
- cout << fixed << setprecision(12) << p;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement