#include using namespace std; int main() { int amount, firstPos, secondPos; double* array; cout << "Enter amount of elements: "; cin >> amount; if (amount < 2) { cout << endl << "Amount of elements must be at least 2"; return 0; } // Выделяем память array = new double[amount]; // Заполняем cout << endl << "Fill array:" << endl; for (int i = 0; i < amount; i++) { cout << i + 1 << ") "; cin >> array[i]; } firstPos = 0; secondPos = 1; // Основная часть, в которой мы, взяв два числа, сравниваем их с теми, что записаны по индексам // firstPos и secondPas, по абсолютной величине их произведения for (int i = 0; i < amount; i++) { for (int j = 0; j < amount; j++) { // Если сравниваем не один и тот же элемент, то if (i != j) { // Если превсоходит по абсолютной величине произведения, сохраняем индексы if (abs(array[i] * array[j]) > abs(array[firstPos] * array[secondPos])) { firstPos = i; secondPos = j; } } } } // Если позиция второго элемента больше чем позиция второго, то меняем if (firstPos > secondPos) { swap(firstPos, secondPos); } // Считаем корень const double root = sqrt(abs(array[firstPos] * array[secondPos])); // Заменяем все элементы с индекса firstPos по secondPos for (int i = firstPos; i <= secondPos; i++) { array[i] = root; } // Выводим результат cout << "Array after applying changes:" << endl; for (int i = 0; i < amount; i++) { cout << array[i] << " "; } return 0; }