Advertisement
DiaxPlayer

Untitled

Feb 18th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. char trojkat(int x1, int y1, int x2, int y2, int x3, int y3)
  2. {
  3.     using std::sqrt;
  4.     using std::pow;
  5.     using std::min;
  6.     using std::max;
  7.     double bok12 = sqrt( pow(x2-x1, 2) + pow(y2-y1, 2) );
  8.     double bok23 = sqrt( pow(x3-x2, 2) + pow(y3-y2, 2) );
  9.     double bok13 = sqrt( pow(x3-x1, 2) + pow(y3-y1, 2) );
  10.    
  11.     double a = min({bok12, bok23, bok13});
  12.     double b = max({
  13.         min(bok12, bok23),
  14.         min(bok12, bok13),
  15.         min(bok23, bok13) });
  16.     double c = max({bok12, bok23, bok13});
  17.    
  18.     double diff = c*c - (a*a + b*b);
  19.    
  20.     if (diff < 0.000001) {
  21.         return 'P';
  22.     } else if (diff > 0) {
  23.         return 'R';
  24.     } else {
  25.         return 'O';
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement