# C++ : N line segment Intersection [closed]

I need to find intersection of N line segments (given by coordinates of start and end points) which are either vertical or horizontal.So I read that Sweep Line Algorithm is a good way to solve this.

But I can't seem to find it's implementation in C++ anywhere on Internet. Can someone provide me it's code in C++ ?

## closed as off-topic by David Richerby, Evil, jmite, D.W.♦Nov 10 '16 at 18:53

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions about software development or programming tools are off-topic here, but can be asked on Stack Overflow." – David Richerby, Evil, jmite, D.W.
If this question can be reworded to fit the rules in the help center, please edit the question.

• I didn't understand what you want to find. N line segments may have many intersections. You need one of them? All of them? Something else? – Karolis Juodelė Nov 9 '16 at 21:55
• Code requests are off-topic here, strict programming questions are also off-topic here. – Evil Nov 9 '16 at 22:57
• @KarolisJuodelė I need all of the intersections. – Sam_Buck Nov 10 '16 at 17:52
• There could be $O(N^2)$ intersections (consider a grid with $N/2$ rows and $N/2$ columns), in which case you need $O(N^2)$ time anyway, which you can achieve with the obvious test-all-pairs algorithm. – j_random_hacker Nov 10 '16 at 18:14
• @j_random_hacker I think you mean $\Theta$, not $O$. – David Richerby Nov 10 '16 at 18:46