10881 - Overlapping Area   

Description

Given two rectangles, find the overlapping area of the rectangles. Calculate the area of these two rectangle after remove the overlapping area.

You need to store these information and result in structures:

typedef struct
{
   int x;
   int y;
   int length;
   int width;
   int leftArea;
} Rect;

 

For example, if the bottom-left vertices, width and length are (0, 0), 5, 4, and (3, 3), 4, 4 of the first and second rectangle, then the overlapping area is 2. The remaining area of the two rectangle are 18 and 14.

Note that

1.      This problem involves three files.

  • function.h: Function definition of area.
  • function.c: Function implementation of area.
  • main.c: A driver program to test your implementation.

You will be provided with main.c and function.h, and asked to implement function.c.

2.     For OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose c compiler) 

       Step 2. Check the results and debug your program if necessary.

 

HINT

function.h

main.c

 

Input

The bottom-left vertices, width and length of the two rectangle.

Output

The remaining area of the two rectangle, each separated by a space.

Note that you don’t need to print “\n” at the end.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10881.c

Partial Judge Header

10881.h

Tags

10401HW11



Discuss