fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. struct Point
  7. {
  8. int x = 0;
  9. int y = 0;
  10. };
  11.  
  12. const int SIZE = 200;
  13.  
  14. typedef std::vector<Point> Points;
  15.  
  16. template <typename Projection>
  17. void processPoints(Points& points, Projection p)
  18. {
  19. std::sort(points.begin(), points.end(), [&](Point& lhs, Point& rhs) { return p(lhs) < p(rhs); });
  20. for (auto& point: points)
  21. {
  22. if (p(point) < SIZE)
  23. {
  24. p(point) = SIZE;
  25. }
  26. }
  27. }
  28.  
  29. void processPointsX(Points& points)
  30. {
  31. processPoints(points, [](Point& p) -> int& { return p.x; });
  32. }
  33.  
  34. void processPointsY(Points& points)
  35. {
  36. processPoints(points, [](Point& p) -> int& { return p.y; });
  37. }
  38.  
  39. int main()
  40. {
  41. Points p;
  42. processPointsY(p);
  43. return 0;
  44. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
Standard output is empty