Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <vector>
- #include <cmath>
- #include <iostream>
- using namespace std;
- class Point
- {
- private:
- int x, y, z;
- public:
- friend bool operator<(const Point& p)
- {
- return (sqrt(x * x + y * y + z * z) < sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
- }
- friend bool operator>(const Point& p)
- {
- return (sqrt(x * x + y * y + z * z) > sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
- }
- static bool difference(const Point& p)
- {
- return (sqrt(x * x + y * y + z * z) < sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
- }
- };
- int main()
- {
- int n;
- cin >> n;
- vector<Point> pts;
- for (int i = 0; i < n; ++i)
- {
- Point obj;
- int x, y, z;
- cin >> x >> y >> z;
- obj.x = x;
- obj.y = y;
- obj.z = z;
- pts.push_back(obj);
- }
- sort(pts.begin(), pts.end()/*, Point::difference*/)
- //stable_sort(pts.begin(), pts.end()/*, Point::difference*/)
- return 0;
- }
Add Comment
Please, Sign In to add comment