Что делает этот код: #include <iostream>
#include <fstream>
using namespace std;

float mod(float num) {
    if (num < 0) num = -num;
    return num;
}

void PrintTask(ofstream& result) {
    result << "ЗАДАНИЕ:\n"
        << "Дано N точек на плоскости. Найти все пары квадратов с вершинами в этих точках,\n"
        << "имеющих наибольшую площадь пересечения. Вывод вершин осуществить против часовой\n"
        << "стрелки. Стороны квадратов расположены параллельно.\n\n"
        << "ОБРАБОТКА ДАННЫХ:\n";
}

bool CalcSize(ifstream& points, ofstream& result, short& n0) {
    bool err = 0;
    points >> n0;
    if (points.eof()) { result << "Файл пуст."; err = 1; return err; }
    if (n0 < 0) { result << "Кол-во точек не может быть отрицательным."; err = 1; return err; }
    if (n0 == 0) { result << "Кол-во точек = 0."; err = 1; return err; }
    if (n0 > 100) { result << "Слишком большое кол-во точек."; err = 1; return err; }
    return err;
}

void GetPoints(ifstream& points, ofstream& protocol, ofstream& result, float** ArrP, 
    short& N0, short& N) {

    points >> noskipws;
    char sym; short crd = 0, count_p = 0;
    while (!points.eof() && count_p < N0) {
        points >> sym;
        if (sym == ' ' || sym == '\t') continue;
        if (sym == '\n') { crd = 0; continue; }
        if (crd == 0) {
            points.seekg(-1, ios::cur);
            points >> *(*(ArrP + count_p) + crd);
            crd++; continue;
        }
        if (crd == 1) {
            points.seekg(-1, ios::cur); points >> *(*(ArrP + count_p) + crd);
            bool flag_same = 0;
            for (short same = 0; same < N0; same++) {
                if (same == count_p) continue;
                if (*(*(ArrP + same) + 0) == *(*(ArrP + count_p) + 0)
                    && *(*(ArrP + same) + 1) == *(*(ArrP + count_p) + 1)) flag_same = 1;
            }
            if (flag_same == 0) {
                protocol << "Получена " << count_p + 1 << "-я точка с координатами ("
                    << *(*(ArrP + count_p) + 0) << ";" 
                    << *(*(ArrP + count_p) + 1) << ")\n";
                crd++; count_p++; continue;
            }
        }
        if (crd == 2) {
            while (sym != '\n' && !points.eof()) points >> sym; points.seekg(-1, ios::cur);
        }
    }
    N = count_p;
    if (N == 0) result << "Кол-во точек = 0.";
    else result << "На обработку взято " << N << " точек." << endl;
}

void GetSquare(ofstream& protocol, ofstream& result, float** ArrP, short N, 
    float*** ArrS, short& count_s) {

    for (short top1 = 0; top1 < N; top1++) {
        for (short top2 = 0; top2 < N; top2++) {
            if (*(*(ArrP + top2) + 0) == *(*(ArrP + top1) + 0)
                && *(*(ArrP + top2) + 1) < *(*(ArrP + top1) + 1)) {
                float side = *(*(ArrP + top1) + 1) - *(*(ArrP + top2) + 1);
                for (short top3 = 0; top3 < N; top3++) {
                    if (*(*(ArrP + top3) + 1) == *(*(ArrP + top2) + 1)
                        && (*(*(ArrP + top3) + 0) - *(*(ArrP + top2) + 0)) == side) {
                        for (short top4 = 0; top4 < N; top4++) {
                            if (*(*(ArrP + top4) + 0) == *(*(ArrP + top3) + 0) && 
                                (*(*(ArrP + top4) + 1) - *(*(ArrP + top3) + 1)) == side) {
                                for (short crd = 0; crd < 2; crd++) {
                                    *(*(*(ArrS + count_s) + 0) + crd) =
                                        *(*(ArrP + top1) + crd);
                                    *(*(*(ArrS + count_s) + 1) + crd) = 
                                        *(*(ArrP + top2) + crd);
                                    *(*(*(ArrS + count_s) + 2) + crd) =
                                        *(*(ArrP + top3) + crd);
                                    *(*(*(ArrS + count_s) + 3) + crd) = 
                                        *(*(ArrP + top4) + crd);
                                }
                                count_s++;
                            }
                        }
                    }
                }
            }
        }
    }
    result << "Построено " << count_s << " квадратов.\n";
}

void CaclArea(ofstream& protocol, float** ArrA, float l, float w,
    short s_1, short s_2) {

    float area = mod(l * w);
    *(*(ArrA + s_1) + s_2) = area;
    protocol << "Площадь пересечения " << s_1 + 1 << "-го и " 
        << s_2 + 1 << "-го квадрата = " << area << endl;
}

void CalсSide(float*** ArrS, short count_s, float** ArrA, ofstream& protocol) {
    for (short s_1 = 0; s_1 < count_s; s_1++) {
        for (short s_2 = 0; s_2 < count_s; s_2++) {
            if (s_2 == s_1) continue;
            float l, w;
            short point_crd = 0; short point_num[4];
            for (short p = 0; p < 4; p++) {
                if (*(*(*(ArrS + s_1) + 0) + 0) < *(*(*(ArrS + s_2) + p) + 0)
                    && *(*(*(ArrS + s_2) + p) + 0) < *(*(*(ArrS + s_1) + 3) + 0)
                    && *(*(*(ArrS + s_1) + 1) + 1) < *(*(*(ArrS + s_2) + p) + 1)
                    && *(*(*(ArrS + s_2) + p) + 1) < *(*(*(ArrS + s_1) + 0) + 1)) 
                {
                    point_num[point_crd] = p; point_crd++;
                }
            }
            switch (point_crd) {
            case 1: {
                short p = (2 + point_num[0]) % 4;
                l = *(*(*(ArrS + s_2) + point_num[0]) + 0) - *(*(*(ArrS + s_1) + p) + 0);
                w = *(*(*(ArrS + s_2) + point_num[0]) + 1) - *(*(*(ArrS + s_1) + p) + 1);
                CaclArea(protocol, ArrA, l, w, s_1, s_2);
                break;
            }
            case 2: {
                if (point_num[0] == 0 && point_num[1] == 3 || point_num[0] == 1 && point_num[1] == 2) {
                    l = *(*(*(ArrS + s_2) + 3) + 0) - *(*(*(ArrS + s_2) + 0) + 0);
                    short p = mod(point_num[0] - 1);
                    w = *(*(*(ArrS + s_2) + point_num[0]) + 1) - *(*(*(ArrS + s_1) + p) + 1);
                }
                else {
                    w = *(*(*(ArrS + s_2) + 0) + 1) - *(*(*(ArrS + s_2) + 1) + 1);
                    short p = mod(point_num[0] - 2);
                    l = *(*(*(ArrS + s_2) + point_num[0]) + 0) - *(*(*(ArrS + s_1) + p) + 0);
                }
                CaclArea(protocol, ArrA, l, w, s_1, s_2);
                break;
            }
            case 4: {
                l = *(*(*(ArrS + s_2) + 3) + 0) - *(*(*(ArrS + s_2) + 0) + 0);
                w = *(*(*(ArrS + s_2) + 0) + 1) - *(*(*(ArrS + s_2) + 1) + 1);
                CaclArea(protocol, ArrA, l, w, s_1, s_2);
                break;
            }
            }

        }
    }
}

void PrintSquare(ofstream& protocol, float*** ArrS, short count) {
    for (short s_1 = 0; s_1 < count; s_1++) {
        protocol << "Построен " << s_1 + 1 << "-й квадрат с вершинами ";
        for (short s_2 = 0; s_2 < 4; s_2++) {
            protocol << "(" << *(*(*(ArrS + s_1) + s_2) + 0) << ";" 
                << *(*(*(ArrS + s_1) + s_2) + 1) << ")";
        }
        protocol << "\n";
    }
}

void PrintСoordinates(ofstream& result, float*** ArrS, short pnt_num) {
    for (short pnt = 0; pnt < 4; pnt++) {
        result << "(" << *(*(*(ArrS + pnt_num) + pnt) + 0) << ","
            << *(*(*(ArrS + pnt_num) + pnt) + 1) << ")";
    }
}

void PrintRes(float** ArrA, float*** ArrS, short count_s, ofstream& result) {
    float max = **ArrA;
    for (short s_1 = 0; s_1 < count_s; s_1++) {
        for (short s_2 = 0; s_2 < count_s; s_2++) {
            if (max < *(*(ArrA + s_1) + s_2)) max = *(*(ArrA + s_1) + s_2);
        }
    }
    result << "\nРЕЗУЛЬТАТ:\n";
    for (short s_1 = 0; s_1 < count_s; s_1++) {
        for (short s_2 = 0; s_2 < count_s && s_1 < count_s; s_2++) {
            if (*(*(ArrA + s_1) + s_2) == max) {
                result << "- Наибольшая площадь пересечения, равная = " 
                    << max << ", у\n  квадрата с вершинами в точках ";
                PrintСoordinates(result, ArrS, s_1);
                result << "\n  и квадрата с вершинами";
                PrintСoordinates(result, ArrS, s_2);
                result << "\n";
                s_1++;
            }
        }
    }
}

void main() {
    setlocale(LC_ALL, "RU");

    ofstream result; result.open("result.txt");
    if (!result.is_open()) { cout << "Не удалось открыть файл для вывода результата."; return; }
    ofstream protocol; protocol.open("protocol.txt");
    if (!protocol.is_open()) { result << "Не удалось открыть протокол."; return; }
    ifstream points; points.open("points.txt");
    if (!points.is_open()) { result << "Не удалось открыть файл с входными данными"; return; }

    PrintTask(result);
    short N0 = 0; short n = 0;
    if (!CalcSize(points, result, N0)) {
        float** ArrP = new float* [N0];
        for (short i = 0; i < N0; i++) ArrP[i] = new float[2];

        GetPoints(points, protocol, result, ArrP, N0, n);

        if (n > 0) {
            float*** ArrS = new float** [n];
            for (short i = 0; i < n; i++) {
                ArrS[i] = new float* [4];
                for (short j = 0; j < 4; j++) ArrS[i][j] = new float[2];
            }

            short count_s = 0;
            GetSquare(protocol, result, ArrP, n, ArrS, count_s);
            PrintSquare(protocol, ArrS, count_s);

            float** ArrA = new float* [count_s];
            for (short i = 0; i < count_s; i++) {
                ArrA[i] = new float [count_s] {};
            }

            CalсSide(ArrS, count_s, ArrA, protocol);
            PrintRes(ArrA, ArrS, count_s, result);

            for (short i = 0; i < count_s; i++) {
                delete[] ArrA[i];
            } delete[] ArrA;

            for (short i = 0; i < N0; i++) delete[] ArrP[i]; delete[] ArrP;

            for (short i = 0; i < 4; i++) {
                for (short j = 0; j < 2; j++) delete[] ArrS[i][j];
                delete[] ArrS[i];
            } delete[] ArrS;
        }
    }
}