Вот код: `
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
#include <algorithm>
using namespace std;
ifstream inf("Text.txt");
void getElements(double *ptrarray, int n) {
int choice;
do {
cout << "Введите 1, если хотите получить элементы матрицы из файла и 2, если элементы матрицы
получаем по формуле" << endl;
cin >> choice;
} while (choice != 1 && choice != 2);
if (choice == 1) {
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
inf >> ptrarray[i][j];
}
else if (choice == 2) {
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) {
if (i == 0)
i++;
if (j == 0)
j++;
ptrarray[i][j] = (2.2 + j sqrt(8.4 * i + 1)) / (pow(10, log(i * j)) + 5);
}
}
}
void fillVector(double** ptrarray, int n, vector<double> vect) {
vector<double> array; // вспомогательный массив, в котором хранятся суммы i-тых строк
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
array[i] += ptrarray[i][j];
for (int i = 0; i < n; i++)
vect[i] = log(array[i]);
for (int i = 0; i < n; i++)
cout << vect[i] << " ";
cout << "\n";
}
void sortArray(double** ptrarray, int n) {
for (int i = 0; i < n; i++)
sort(ptrarray[i], ptrarray[i] + n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
cout << ptrarray[i][j] << " ";
cout << "\n";
}
}
double calculate_y(vector<double> vect, int n) {
double y = 0;
for (int i = 2; i <= n - 1; i++)
y += (vect[i - 1] / vect[i] + vect[i] / vect[i + 1]);
return y;
}
int main()
{
setlocale(LC_ALL, "Russian");
cout << "Введите размер матрицы" << endl;
int n;
cin >> n;
double** ptrarray = new double* [n];
for (int i = 0; i < n; i++)
ptrarray[i] = new double[n];
vector<double> vect;
getElements(ptrarray, n);
fillVector(ptrarray, n, vect);
sortArray(ptrarray, n);
cout << "y = " << calculate_y(vect, n);
}
`
Подскажите пожалуйста, как исправить