Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include<cmath>
- using namespace std;
- class Point
- {
- public:
- Point(string name = "",float x = 0,float y=0):name_(name),x_(x),y_(y){}
- float getX()const
- {
- return x_;
- }
- float getY()const
- {
- return y_;
- }
- string getName()const
- {
- return name_;
- }
- friend bool operator<(const Point& lhs, const Point& rhs);
- protected:
- float x_;
- float y_;
- string name_;
- };
- bool operator<(const Point&lhs,const Point&rhs)
- {
- const float lhs1 = sqrt((lhs.x_ * lhs.x_) + (lhs.y_ * lhs.y_));
- const float rhs1= sqrt((rhs.x_ * rhs.x_) + (rhs.y_ * rhs.y_));
- if (lhs1 == rhs1)
- {
- if (lhs.name_.length() < rhs.name_.length())
- {
- return lhs1 < rhs1;
- }
- else if (lhs.name_.length() == rhs.name_.length())
- {
- return lhs1 > lhs1;
- }
- }
- else
- return lhs1 < rhs1;
- }
- class Circle:public Point
- {
- public:
- Circle(string name = "", float x = 0, float y = 0,string nameC="",float radius=0):Point(name,x,y),nameC_(nameC),radius_(radius){}
- float getRadius()const
- {
- return radius_;
- }
- string getNameC()const
- {
- return nameC_;
- }
- private:
- float radius_;
- string nameC_;
- };
- class Cords
- {
- public:
- static const int size_ = 20;
- int counter_ = 0;
- Point array_[size_];
- int getCounter() const { return counter_; }
- void Add(const Point toAdd)
- {
- array_[counter_] = toAdd;
- counter_++;
- if(counter_<size_)
- {
- for(int i=0;i<counter_;i++)
- {
- for(int j=0;j<counter_-1;j++)
- {
- if (array_[j] < array_[j + 1])
- swap(array_[j], array_[j + 1]);
- }
- }
- }
- }
- void disp(int index)
- {
- cout << array_[index].getName() << " " << array_[index].getX() << " " << array_[index].getY() << " ";
- }
- bool check(const Circle circle) const
- {
- for(int i=0;i<counter_;i++)
- {
- if (sqrt(array_[i].getX() * array_[i].getX() + array_[i].getY() * array_[i].getY()) > circle.getRadius()){
- return false; }
- }
- return true;
- }
- };
- int main()
- {
- Cords object;
- float x, y;
- string name;
- cin >> name >> x >> y;
- Point point1(name, x, y);
- cin >> name >> x >> y;
- Point point2(name, x, y);
- cin >> name >> x >> y;
- Point point3(name, x, y);
- cin >> name >> x >> y;
- Point point4(name, x, y);
- cin >> name >> x >> y;
- Point point5(name, x, y);
- cin >> name >> x >> y;
- Point point6(name, x, y);
- object.Add(point1);
- object.Add(point2);
- object.Add(point3);
- object.Add(point4);
- object.Add(point5);
- object.Add(point6);
- for(int i=0;i<6;i++)
- {
- object.disp(i);
- }
- string nameC;
- float radius;
- cin >> name >> x >> y >> nameC >> radius;
- Circle circle(name,x,y, nameC, radius);
- cout << object.check(circle);
- }
- // 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