fork download
  1. #include <iostream>
  2. #include <utility>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. int main ()
  7. {
  8. // for non-predicate version of std::sort, point needs an operator <
  9. // for non-predicate version of std::unique, point needs an operator ==
  10. // for brevity, using a std::pair<> which has both
  11. using point = std::pair<int,int> ;
  12.  
  13. std::vector< point > my_points { {2,4}, {5,4}, {2,4}, {0,1}, {5,4}, } ;
  14. std::sort( my_points.begin(), my_points.end() ) ;
  15. my_points.erase( std::unique( my_points.begin(), my_points.end() ), my_points.end() ) ;
  16.  
  17. for( point p : my_points ) std::cout << '(' << p.first << ',' << p.second << ") " ;
  18. std::cout << '\n' ;
  19. }
  20.  
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
(0,1) (2,4) (5,4)