Advertisement
Guest User

Untitled

a guest
May 28th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1. #include <stdafx.h>
  2. #include <iostream>
  3. #include <math.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int x, y, x1, y1, x2, y2;
  11.  
  12.     cin >> x >> y >> x1 >> y1 >> x2 >> y2;
  13.  
  14.     float l1 = sqrt((float)((x - x1)*(x - x1) + (y - y1)*(y - y1)));
  15.     float l2 = sqrt((float)((x - x2)*(x - x2) + (y - y2)*(y - y2)));
  16.     float l3 = sqrt((float)((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)));
  17.  
  18.     float p = (l1 + l2 + l3) / 2;
  19.     float s = sqrt((float)(p*(p - l1)*(p - l2)*(p - l3)));
  20.     float h = 2 * s / l3;
  21.     if ((l1*l1 + l3 * l3 - l2 * l2 >= 0) && (l2*l2 + l3 * l3 - l1 * l1 >= 0)) {
  22.         cout << setprecision(4) << fixed << h;
  23.         cout <<"sosi1"<< endl ;
  24.     }
  25.     else {
  26.         cout << "sosi2" << endl;
  27.         if (l1 < l2) {
  28.             cout << setprecision(4) << fixed << l1;
  29.         }
  30.         else {
  31.             cout << setprecision(4) << fixed << l2;
  32.         }
  33.     }
  34.     system("pause");
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement