Assignment 3: nested rectangles

Write a program in C++ that sums up the areas of nested rectangles given as following figure;

We assume that no rectangle overlaps with others. The black rectangles indicate the leaf rectangles while white rectangles are containers of other white or black rectangles. Each rectangle is represented by its two corner points (x1,y1) and (x2,y2) where x1<x2 and y1<y2. Your program in C++ sums the areas of black rectangle in recursive way using generalized list and prints it.

The input file (nested.inp) is given as

n // the number of rectangles (white and black)

A w B C D K //w means that A is a white rectangle containing B, C, D, and K

B w J //B contains J

J b x1 y1 x2 y2 //b means that J is a black rectangle with two corner points (x1,y1) and (x2,y2)

M b x1 y1 x2 y2

The output file (nested.out) contains the area as an integer value.

The program should be submitted via ESPA by Nov. 15, 6:00 pm.