Question

# C++ program for : 1. Given an array of real numbers and the dimension n (n...

C++ program for :

1. Given an array of real numbers and the dimension n (n is entered from the keyboard). B form an array, each element bi - arithmetic mean of the array elements and excluding ai.
2. Given an array of integers dimension n. Change the array so that all the elements of the module which is not equal to the maximum element of the array, replaced by zero, and equal - unit.
3. Given an array of dimension n (even). If the array elements in ascending order, to remove the elements of the array by one, starting with the first, or - insert into the middle element of the array is equal to the first, "contrary to" the condition of the increase. An additional array can not be used.
4. Dana matrix of nxm. Get a one-dimensional array a [m], keeping the sum of the elements corresponding to the columns of which are prime numbers.

Here are the functions for the first 2 methods.

#include <iostream>
using namespace std;
//1. Given an array of real numbers and the dimension n (n is entered from the keyboard).
//B form an array, each element bi - arithmetic mean of the array elements and excluding ai.
double* arrayOfMeans(double array[], int n)
{
double *newArray = new double[n];
double sum = 0.0;
for(int i = 0; i < n; i++)
sum += array[i];
for(int i = 0; i < n; i++)
newArray[i] = (sum - array[i]) / n-1;
return newArray;
}
//Given an array of integers dimension n. Change the array so that all the elements of the
//module which is not equal to the maximum element of the array, replaced by zero, and equal - unit.
void modifyElementsOfArray(int array[], int n)
{
int maxElement = array[0];
for(int i = 1; i < n; i++)
if(array[i] > maxElement)
maxElement = array[i];
for(int i = 0; i < n; i++)
if(array[i] != maxElement)
array[i] = 0;
else
array[i] = 1;
}

#### Earn Coins

Coins can be redeemed for fabulous gifts.