Exercises: Methods - Problem 12. Rectangle Intersection
Здравейте,
Решавам тази задача, но последния тест ми гърми и не мога да разбера защо. Можете ли да ме насочите към евентуалния проблем?
http://pastebin.com/Y897wCVh
Problem 12. Rectangle Intersection
Create a class Rectangle. It should consist of an ID, width, height and the coordinates of its top left corner (horizontal and vertical). Create a method which receives as a parameter another Rectangle, checks if the two rectangles intersect and returns true or false.
On the first line you will receive the number of rectangles – N and the number of intersection checks – M. On the next N lines, you will get the rectangles with their ID, width, height and coordinates. On the last M lines, you will get pairs of IDs which represent rectangles. Print if each of the pairs intersect.
You will always receive valid data. There is no need to check if a rectangle exists.
Examples
Input |
Output |
2 1 Pesho 2 2 0 0 Gosho 2 2 0 0 Pesho Gosho |
true |