Advertisement
Guest User

Untitled

a guest
Sep 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double x1, y1,
  10. x2, y2,
  11. x3, y3;
  12.  
  13. cin >> x1 >> y1;
  14. cin >> x2 >> y2;
  15. cin >> x3 >> y3;
  16.  
  17. double a = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
  18. double b = sqrt((x2-x3)*(x2-x3) + (y2-y3)*(y2-y3));
  19. double c = sqrt((x1-x3)*(x1-x3) + (y1-y3)*(y1-y3));
  20.  
  21. double p = a + b + c;
  22. double p2 = p / 2.0;
  23.  
  24. cout << fixed
  25. << setprecision(6)
  26. << p << " ";
  27.  
  28. cout << fixed
  29. << setprecision(6)
  30. << sqrt(p2*(p2-a)*(p2-b)*(p2-c));
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement