Advertisement
Guest User

Untitled

a guest
Jul 25th, 2018
701
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. vector<pair<long long, long long> > points;
  2.  
  3. struct cmpr{
  4. cmpr(pair<long long, long long> p0){
  5. this->p0.first = p0.first;
  6. this->p0.second = p0.second;
  7. }
  8. bool operator()(pair<long long, long long> lPoint, pair<long long, long long> rPoint){
  9. long long orient = (lPoint.second-p0.second)*(rPoint.first-lPoint.first) -
  10. (lPoint.first-p0.first)*(rPoint.second-p0.second);
  11. if(orient < 0) return false;
  12. return true;
  13. }
  14. pair<long long, long long> p0;
  15. };
  16.  
  17. void CCRSort(){
  18. /* p[0] has the smallest y value of all points */
  19. sort(points.begin(), points.end(), cmpr(points[0]);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement