Question

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.

Answer #1

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;

}

Write recursive method to return true if a given array of
integers, named numbers, with n occupied positions is sorted in
ascending (increasing) order, or returns false otherwise. Array can
be empty or not.
//PRECONDITION: Varible n denotes the number of occupied
positions in the array and must be non-negative.
Employee class has method getSalary() that returns employee's
salary.
// An empty array and an array with single element in it, are
sorted. Method isSortedRec must be recursive and
returns...

C program question:
Write a small C program connect.c that:
1. Initializes an array id of N elements with the value of the
index of the array.
2. Reads from the keyboard or the command line a set of two
integer numbers (p and q) until it encounters EOF or CTL - D
3. Given the two numbers, your program should connect them by
going through the array and changing all the entries with the same
name as p to...

1. Given an
n-element array A, Algorithm X executes an
O(n)-time computation for each even
number in A and an O(log n)-time computation for
each odd number in A.
What is the best-case running time of Algorithm X?
What is the worst-case running time of Algorithm X?
2. Given an array,
A, of n integers, give an O(n)-time algorithm that finds
the longest subarray of A such that all the numbers in that
subarray are in sorted order. Your algorithm...

Write a code in c++ using linear insertion following the steps
below. Comment your work.
1. Ask the user for the name of a file containing
data. If it does not exist, the program should display an error,
then ask for a new file name. Entering an asterisk (*) as the first
and only character on a line should terminate the program.
2. You can use a statically-allocated
one-dimensional array of doubles for this with length 100. You...

What tools could AA leaders have used to increase their
awareness of internal and external issues?
???ALASKA AIRLINES: NAVIGATING CHANGE
In the autumn of 2007, Alaska Airlines executives adjourned at
the end of a long and stressful day in the
midst of a multi-day strategic planning session. Most headed
outside to relax, unwind and enjoy a bonfire
on the shore of Semiahmoo Spit, outside the meeting venue in
Blaine, a seaport town in northwest
Washington state.
Meanwhile, several members of...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 1 minute ago

asked 1 minute ago

asked 21 minutes ago

asked 35 minutes ago

asked 39 minutes ago

asked 39 minutes ago

asked 39 minutes ago

asked 43 minutes ago

asked 43 minutes ago

asked 50 minutes ago

asked 51 minutes ago

asked 55 minutes ago