fork download
  1. void add_point_to_vertexs(set<Point> &vertexs, Point px)
  2. {
  3. for (p1 : vertexs)
  4. for (p2 : vertexs)
  5. if (((p2.x - p1.x) * (px.y - p1.y) - (p2.y - p1.y) * (px.x - p1.x)) == 0 &&
  6. ((p2.x - p1.x) * (px.x - p1.x) + (p2.y - p1.y) * (px.y - p1.y)) > 0 &&
  7. ((p2.x - p1.x - px.x) * (px.x - p1.x) + (p2.y - p1.y - px.y) * (px.y - p1.y)) <= 0)
  8. vertexs.erase(p2); // p2 lies on line(p1, px)
  9.  
  10. vertexs.push(px);
  11. }
  12.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty