Overlapping rectangles determine whether two rectangles overlap the problem C + +

Source: Internet
Author: User

Given, rectangles, find if the Given is rectangles overlap or not.

A rectangle is denoted by providing the X and Y co-ordinates of, points:the left top corner and the right bottom Corne R of the rectangle.

Note that the rectangles sharing a side is considered overlapping.

Input:

The first integer T denotes the number of test cases. For every test case, there is 2 lines of input. The first line consists of 4 integers:denoting the co-ordinates of the 2 points of the first rectangle. The first integer denotes the x co-ordinate and the second integer denotes the y co-ordinate of the left topmost corner of The first rectangle. The next integers is the x and Y co-ordinates of right bottom corner. Similarly, the second line denotes the cordinates of the and the points second of the.


Output:

For each test case, output (either 1 or 0) denoting whether the 2 rectangles is overlapping. 1 denotes the rectangles overlap whereas 0 denotes the rectangles do not overlap.


Constraints:

1 <= T <= 10

-10000 <= x, y <= 10000

T denotes the number of test cases. x denotes the x co-ordinate and y denotes the y co-ordinate.


Example:

Input: 2 0 Ten Ten 0 5 5  the 0 0 2 1 1-2 -302Output:10

Here is my Code implementation:

Overlapping rectangles determine whether two rectangles overlap the problem C + +

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.