ФІО = GVA Запитання:/* 3. У файлі задано координати вершин прямокутників (кожен прямокутник задано четвіркою чисел, які означають дві пари координат протилежних вершин). Відсортувати у файлі координати по зменшенню площі прямокутників. - IN FILE EXAMPLE - - - 1 1 2 2 11 12 13 15 1 1 3 3 5 5 10 10 5 6 7 8 12 17 -9 -5 -10 -10 -15 -20 - - - - - - - - - - - - */ #include "stdafx.h" #include #include #include #include using namespace std; struct MyRectangle{ long x1; long x2; long y1; long y2; long s; }; void RectSwap(MyRectangle *a, MyRectangle *b) { MyRectangle temp = *a; *a = *b; *b = temp; } long GetSquare(MyRectangle *r) { return ( (r->x2 - r->x1)*(r->y2- r->y1) ); } void PrintAllRectangles(MyRectangle *r, int count) { for (int i = 0 ; i < count ; i++) { cout<x1) <<" ; " << ((r+i)->y1) <<" ) x ("<< ((r+i)->x2) <<" ; " << ((r+i)->y2) <<" ) ; "<< ((r+i)->s) <s < (r+j)->s ) {// need swap RectSwap(r+i,r+j); } } } int _tmain(int argc, _TCHAR* argv[]) { string IN_FILE_NAME = "in.txt"; string OUT_FILE_NAME = "out.txt"; int dataCount = 0; int linesCount = 0; // открываем файл на вход ifstream fin; fin.open(IN_FILE_NAME); if (fin.is_open()) { cout<<"File opened!"<>temp; dataCount++; } cout<<"DATA COUNT : "<> (rectangleList+i)->x1; fin>> (rectangleList+i)->y1; fin>> (rectangleList+i)->x2; fin>> (rectangleList+i)->y2; // и сразу считаем площадь (rectangleList+i)->s = GetSquare(rectangleList+i); } fin.close(); PrintAllRectangles(rectangleList,linesCount); cout<x1 )<<" " <<( (rectangleList+i)->y1 )<<" " <<( (rectangleList+i)->x2 )<<" " <<( (rectangleList+i)->y2 )<