Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Point {
- private:
- string name_;
- double x_, y_;
- public:
- Point(string name, double x, double y) : name_(name), x_(x), y_(y){}
- Point() {}
- double getSum() { return x_ + y_;}
- string getName() { return name_;}
- double getX() { return x_;}
- double getY() { return y_;}
- };
- ///////////////////////////////
- ostream & operator<<(ostream & s, Point & object) {
- return s << object.getName() << " " << object.getX() << " " << object.getY() << " ";
- }
- ///////////////////////////////
- int size;
- bool operator<(Point object1, Point object2) {
- if(object1.getSum() == object2.getSum()) {
- if(object1.getX() == object2.getX()) {
- if(object1.getName().size() < object2.getName().size())
- size = object1.getName().size();
- else
- size = object2.getName().size();
- for(int i = 0; i<size; i++) {
- if(object1.getName()[i] != object2.getName()[i])
- return object1.getName()[i] < object2.getName()[i];
- }
- }
- return (object1.getX() < object2.getX());
- }
- return object1.getSum() < object2.getSum();
- }
- // ======================================================================
- // main
- // ======================================================================
- int main() {
- string name;
- double x, y;
- list<Point> pList;
- Iterator <Point> pIterator(pList);
- int n;
- cin >> n;
- Point *objects = new Point[n];
- for(int i = 0; i<n; i++) {
- cin >> name >> x >> y;
- objects[i] = Point(name, x, y);
- }
- for(int i = 0; i<n-1; i++)
- for(int j = 0; j<n-i-1; j++)
- if(objects[j]<objects[j+1])
- swap(objects[j], objects[j+1]);
- for(int i = 0; i<n; i++)
- pList.add(objects[i]);
- cin >> x;
- for(pIterator.init(); !pIterator; pIterator++)
- if((pIterator().getSum()) == x)
- pIterator.remove_current();
- for(pIterator.init(); !pIterator; pIterator++) {
- objects[0] = pIterator();
- cout << objects[0];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement