Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<cmath>
  4.  
  5. using namespace std;
  6.  
  7. class Point
  8. {
  9. public:
  10. Point(string name = "",float x = 0,float y=0):name_(name),x_(x),y_(y){}
  11. float getX()const
  12. {
  13. return x_;
  14. }
  15. float getY()const
  16. {
  17. return y_;
  18. }
  19. string getName()const
  20. {
  21. return name_;
  22. }
  23.  
  24. friend bool operator<(const Point& lhs, const Point& rhs);
  25. protected:
  26. float x_;
  27. float y_;
  28. string name_;
  29. };
  30.  
  31.  
  32. bool operator<(const Point&lhs,const Point&rhs)
  33. {
  34. const float lhs1 = sqrt((lhs.x_ * lhs.x_) + (lhs.y_ * lhs.y_));
  35. const float rhs1= sqrt((rhs.x_ * rhs.x_) + (rhs.y_ * rhs.y_));
  36.  
  37. if (lhs1 == rhs1)
  38. {
  39. if (lhs.name_.length() < rhs.name_.length())
  40. {
  41. return lhs1 < rhs1;
  42. }
  43. else if (lhs.name_.length() == rhs.name_.length())
  44. {
  45. return lhs1 > lhs1;
  46. }
  47. }
  48. else
  49. return lhs1 < rhs1;
  50. }
  51.  
  52. class Circle:public Point
  53. {
  54. public:
  55. Circle(string name = "", float x = 0, float y = 0,string nameC="",float radius=0):Point(name,x,y),nameC_(nameC),radius_(radius){}
  56. float getRadius()const
  57. {
  58. return radius_;
  59. }
  60. string getNameC()const
  61. {
  62. return nameC_;
  63. }
  64. private:
  65. float radius_;
  66. string nameC_;
  67. };
  68.  
  69.  
  70.  
  71. class Cords
  72. {
  73. public:
  74. static const int size_ = 20;
  75. int counter_ = 0;
  76. Point array_[size_];
  77. int getCounter() const { return counter_; }
  78.  
  79. void Add(const Point toAdd)
  80. {
  81. array_[counter_] = toAdd;
  82. counter_++;
  83. if(counter_<size_)
  84. {
  85. for(int i=0;i<counter_;i++)
  86. {
  87. for(int j=0;j<counter_-1;j++)
  88. {
  89. if (array_[j] < array_[j + 1])
  90. swap(array_[j], array_[j + 1]);
  91. }
  92. }
  93. }
  94. }
  95. void disp(int index)
  96. {
  97. cout << array_[index].getName() << " " << array_[index].getX() << " " << array_[index].getY() << " ";
  98. }
  99. bool check(const Circle circle) const
  100. {
  101. for(int i=0;i<counter_;i++)
  102. {
  103. if (sqrt(array_[i].getX() * array_[i].getX() + array_[i].getY() * array_[i].getY()) > circle.getRadius()){
  104. return false; }
  105. }
  106. return true;
  107. }
  108. };
  109. int main()
  110. {
  111. Cords object;
  112. float x, y;
  113. string name;
  114.  
  115. cin >> name >> x >> y;
  116. Point point1(name, x, y);
  117. cin >> name >> x >> y;
  118. Point point2(name, x, y);
  119. cin >> name >> x >> y;
  120. Point point3(name, x, y);
  121. cin >> name >> x >> y;
  122. Point point4(name, x, y);
  123. cin >> name >> x >> y;
  124. Point point5(name, x, y);
  125. cin >> name >> x >> y;
  126. Point point6(name, x, y);
  127.  
  128. object.Add(point1);
  129. object.Add(point2);
  130. object.Add(point3);
  131. object.Add(point4);
  132. object.Add(point5);
  133. object.Add(point6);
  134. for(int i=0;i<6;i++)
  135. {
  136. object.disp(i);
  137. }
  138. string nameC;
  139. float radius;
  140. cin >> name >> x >> y >> nameC >> radius;
  141. Circle circle(name,x,y, nameC, radius);
  142. cout << object.check(circle);
  143. }
  144.  
  145.  
  146. // p0 1 1 p1 2 2 p3 5 5 p4 1 1 p5 0.5 0.5 p 1 1 Pk 1 1 k1 10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement