Wednesday, November 14, 2018

problem 7

Fencing the ground

Two non-overlapping fields need to be fenced together to guard from cattle. The fence is always a single rectangle, which cover the two fields exactly.

Given the left bottom coordinate, length and width of the two fields, write a program to find dimension of the fence. Print “Invalid Input” if the fields overlap. 
  
Input Format:
The 1st line of the input consists of 4 integers separated by a space that correspond to x, y, l and w of the first rectangle.
The 2nd line of the input consists of 4 integers separated by a space that correspond to x, y, l and w of the second rectangle.
Output Format:
Output consists of 4 integers that correspond to x, y, l and w of the Union rectangle.

Sample Input 1: 
0 2 4 3 
4 0 2 8 
Sample Output 1: 
0 0 6 8 
  
Sample Input 2: 
0 2 4 3 
3 0 2 8 
Sample Output 2: 
Invalid Input

No comments:

 https://meet.google.com/bjp-tnpc-zee