Advertisement
evgenko

Untitled

Mar 11th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define x first
  3. #define y second
  4.  
  5. using namespace std;
  6.  
  7. void sayNo(int n){
  8.     for (int i=0;i<n;i++){
  9.         cout << "NO" << endl;
  10.     }
  11. }
  12. float kos_pr(pair<float,float> p1, pair<float, float> p2, pair<float, float> p3){
  13.     pair<float, float> v1;
  14.     pair<float, float> v2;
  15.     v1.x = p2.x-p1.x;
  16.     v1.y = p2.y-p1.y;
  17.     v2.x = p3.x-p1.x;
  18.     v2.y = p3.y-p1.y;
  19.     return v1.x*v2.y - v1.y*v2.x;
  20. }
  21. float sc_pr(pair<float,float> p1, pair<float, float> p2, pair<float, float> p3){
  22.     pair<float, float> v1;
  23.     pair<float, float> v2;
  24.     v1.x = p2.x-p1.x;
  25.     v1.y = p2.y-p1.y;
  26.     v2.x = p3.x-p1.x;
  27.     v2.y = p3.y-p1.y;
  28.     return v1.x*v2.x + v1.y*v2.y;
  29. }
  30. int main() {
  31.     ios_base::sync_with_stdio(false);
  32.     cin.tie(NULL);
  33.     float k,b;
  34.     pair<float, float> points[3];
  35.     for (int i=0;i<3;i++){
  36.         cin >> points[i].x;
  37.         cin >> points[i].y;
  38.     }
  39.     k = (points[1].y - points[2].y)/(points[1].x - points[2].x);
  40.     b = points[2].y - k * points[2].x;
  41.  
  42.     if (kos_pr(points[0],points[1],points[2])==0){
  43.         cout << "YES" << endl;
  44.         if (sc_pr(points[1], points[2], points[0]) >=0){
  45.             cout << "YES" << endl;
  46.             if (sc_pr(points[0], points[1], points[2]) <= 0){
  47.                 cout << "YES";
  48.             }else{
  49.                 cout << "NO";
  50.             }
  51.         } else{
  52.             sayNo(2);
  53.         }
  54.     }else{
  55.         sayNo(3);
  56.     }
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement