awsmpshk

Номера 1 и 2 к 21.05, Кузичкин 141 группа

May 20th, 2020
106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <vector>
  3. #include <cmath>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. class Point
  9. {
  10. private:
  11.   int x, y, z;
  12. public:
  13.   friend bool operator<(const Point& p)
  14.   {
  15.     return (sqrt(x * x + y * y + z * z) < sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
  16.   }
  17.   friend bool operator>(const Point& p)
  18.   {
  19.     return (sqrt(x * x + y * y + z * z) > sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
  20.   }
  21.  
  22.   static bool difference(const Point& p)
  23.   {
  24.     return (sqrt(x * x + y * y + z * z) < sqrt(p.x * p.x + p.y * p.y + p.z * p.z));
  25.   }
  26. };
  27.  
  28. int main()
  29. {
  30.   int n;
  31.   cin >> n;
  32.   vector<Point> pts;
  33.   for (int i = 0; i < n; ++i)
  34.   {
  35.     Point obj;
  36.     int x, y, z;
  37.     cin >> x >> y >> z;
  38.     obj.x = x;
  39.     obj.y = y;
  40.     obj.z = z;
  41.     pts.push_back(obj);
  42.   }
  43.   sort(pts.begin(), pts.end()/*, Point::difference*/)
  44.   //stable_sort(pts.begin(), pts.end()/*, Point::difference*/)
  45.   return 0;
  46. }
RAW Paste Data Copied