Consider a string of n pairs of intervals of the form [ai, bi], [ci, di] with ai, bi, ci and di being integers. A pair of intervals intersects each other if they have at least one point in common. Determine the maximum number (nmax) of pairs of intervals that intersect, and the respective intersections.
Entrance. In the inters.in text file, the number n is on the first line, and on each of the following n lines, five integers: i, ai, bi, ci and di (separated by spaces), which represent respectively: i – the number of the line , followed by the ends of the intervals in line i.
Exit. The textual file inters.out will contain data about the intersections of the intervals: on the first line nmax – their number, and on the following nmax lines, three numbers each, separated by space: i, followed by the extremities of the intersection interval i, ordered by their left extremities
Example
inters.in
5
1 1 3 7 23
2 4 12 5 6
3 3 5 6 8
4 0 7 7 9
5 -2 5 3 6
inters.out
3
5 3 5
2 5 6
4 7 7
i need this program in c++ used with the method struct