Advertisement
Guest User

My code

a guest
Nov 6th, 2011
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include <iostream>                                                                        
  2. #include <math.h>
  3. #include <algorithm>
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <cstring>
  8. using namespace std;
  9. int main () {
  10.     #ifndef ONLINE_JUDGE
  11.        freopen ("input.txt", "r", stdin);
  12.        freopen ("output.txt", "w", stdout);
  13.     #endif
  14.     int x, y, x1, y1, x2, y2;
  15.     scanf ("%d%d", &x, &y);                         // x - x1 / x2 - x1 = y - y1 / y2 - y1
  16.     scanf ("%d%d%d%d", &x1, &y1, &x2, &y2);
  17.     double AB = sqrt ((double) (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  18.     double AO = sqrt ((double) (x - x1) * (x - x1) + (y - y1) * (y - y1));
  19.     double OB = sqrt ((double) (x - x2) * (x - x2) + (y - y2) * (y - y2));
  20. //    cout << AB << " " << AO << " " << OB << "\n";
  21.     if (! (round (AO) + round (OB) == round (AB)))
  22.     {
  23.         printf ("NO");
  24.         exit (0);
  25.     }
  26. //    cout << "ok";
  27.     if (y2 - y1 == 0 && x2 - x1 == 0 || x - x1 == 0 || y - y1 == 0)
  28.     {
  29.         printf ("YES");
  30.         exit (0);
  31.     }
  32.     else if (! (y2 - y1 == 0 && x2 - x1 == 0) && (x2 - x1 == 0 || y2 - y1 == 0))
  33.     {
  34.         printf ("NO");
  35.         exit (0);
  36.     }
  37. //    cout << "ok";
  38.     double a = (x - x1) / (x2 - x1);
  39.     double b = (y - y1) / (y2 - y1);
  40. //    cout << a << " " << b << "\n";
  41.     if (a == b)
  42.         printf ("YES");
  43.     else printf ("NO");
  44. return 0;
  45. }
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement