Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following struct definitions, which represent a point on the Cartes

ID: 3632435 • Letter: C

Question

Consider the following struct definitions, which represent a point on the Cartesian plan, and a rectangular region on the Cartesian plane, respectively.

struct point {
int x; /* x coordinate */
int y; /* y coordinate */
};

struct rectangle {
struct point bottomLeft;
struct point topRight;
};


Write a function named "sort" that sorts an array of rectangles, smallest to largest. Two rectanges are ordered with each other according to the following rules:
The rectangle with the smaller area is less.
If the areas are the same, then the rectangle that begins further to the left is less.
If the starting x-coordinates are equal, then the rectangle that begins at a lower point is less.
If the starting x- and y-coordinates are equal, then the shorter rectangle is less.

The function takes two arguments: an array of struct rectangle, and the size of the array (an integer).

void sort(struct rectangle *array, int size);

You may define additional functions in your solution.

Please help, Thank you!

Explanation / Answer

#include #include #include "apstring.cpp" struct PRINTER_TYPE { apstring brand; int modelNumber; double cost; } ; void sort(apvector &printerStock); int main(void) { apvector printerStock(30); . . . sort (printerStock); . . . } // function to sort array of structures . . . abc order by brand void sort (apvector &printerStock) { PRINTER_TYPE temp; for(int i = 0; i