KuzzR

triangle

Sep 10th, 2021 (edited)
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int triangle() {
  8.  
  9.   int x1, y1, x2, y2, x3, y3;
  10.   float a, b, c, P, S;
  11.   cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
  12.   a = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
  13.   b = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
  14.   c = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
  15.   P = a + b + c;
  16.   S = sqrt(P/2 * (P/2 - a) * (P/2 - b) * (P/2 - c));
  17.   cout << P << endl <<  S;
  18.  
  19.   return 0;
  20. }
Add Comment
Please, Sign In to add comment