#include "Rectangle.h" #include #include using namespace std; Rectangle *sortBySelection(Rectangle rectInAndOut[], int size) { for (int i = 0; i < size; i++) { int sm = i; double sv = rectInAndOut[i].getArea(); for (int j = i + 1; j < size; j++) { if (rectInAndOut[j].getArea() < sv) { sv = rectInAndOut[j].getArea(); sm = j; } } Rectangle t = rectInAndOut[sm]; rectInAndOut[sm] = rectInAndOut[i]; rectInAndOut[i] = t; } return rectInAndOut; } int main() { const int arrSize = 10; Rectangle rectArr[arrSize]; double width, height; for (int i = 0; i < arrSize; i++) { cin >> width >> height; rectArr[i] = Rectangle(width, height); } cout << "----- Original Array -----" << endl; for (int i = 0; i < arrSize; i++) { cout << fixed << setprecision(2) << rectArr[i].getArea() << endl; } Rectangle *returnArray = sortBySelection(rectArr, arrSize); cout << "----- Sorted Array -----" << endl; for (int i = 0; i < arrSize; i++) { cout << fixed << setprecision(2) << rectArr[i].getArea() << endl; } cout << "----- Return Sorted Array -----" << endl; for (int i = 0; i < arrSize; i++) { cout << fixed << setprecision(2) << returnArray[i].getArea() << endl; } }