Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include<math.h>  
  4. using namespace std;
  5.  
  6. class Coordinates
  7. {
  8. public:
  9.     Coordinates() {}
  10.      double x;
  11.      double y;
  12.     Coordinates(double x, double y)
  13.     {
  14.         this->x = x;
  15.         this->y = y;
  16.     }
  17. };
  18. class  Hamster :public Coordinates
  19. {
  20. public:
  21.     Hamster(double x, double y):Coordinates(x, y) {}
  22. };
  23. class  Dog :public Coordinates
  24. {
  25. public:
  26.     Dog(double x, double y) :Coordinates(x, y) {}
  27. };
  28. class  Den:public Coordinates
  29. {
  30. public:
  31.     Den() {};
  32.     Den(double x, double y) :Coordinates(x, y) {}
  33. };
  34. int main()
  35. {
  36.     double x1, y1, x2, y2, n,x,y;
  37.     int g = 0;
  38.     cin >> x1 >> y1 >> x2 >> y2 >> n;
  39.     Hamster FastHamster(x1, y1);
  40.     Dog AgryDog(x2,y2);
  41.     for (int i = 0; i < n; i++)
  42.     {
  43.         cin >> x >> y;
  44.         if (sqrtl(pow((FastHamster.x - x), 2) + pow((FastHamster.y - y), 2))<=(sqrtl(pow((AgryDog.x - x), 2) + pow((AgryDog.y - y), 2)) / 2)&&g==0 ) {
  45.             cout << i+1;
  46.             g++;
  47.             break;
  48.         }
  49.     }  
  50.     if(g==0)cout << "NO";
  51.     return 0;
  52.  
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement