1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <iostream>
using namespace std;
int populate_Array(double array[], int number);
void display_Array(double array[], int number);
void sum_Array(double array[], int number);
void invert_Array(double array[], int number);
void max_Array(double array[], int number);
int _tmain(int argc, _TCHAR* argv[])
{
const int Number = 6;
double total[6] = {};
int number = populate_Array(total, Number);
display_Array(total, number);
sum_Array(total, number);
invert_Array(total + 1, number - 2);
max_Array(total, number);
return 0;
}
int populate_Array(double array[], int number)
{
double input;
int i;
for (i = 0; i < number; i++)
{
cout << "Please enter an integer: " << (i + 1) << ": ";
cin >> input;
array[i] = input;
}
cout << endl;
return i;
}
void display_Array(double array[], int number)
{
int sum = 0;
cout << "The elements of the array are: ";
for (int i = 0; i < number; i++)
{
cout << array[i] << ", ";
}
cout << endl;
}
void sum_Array(double array[], int number)
{
double sum = 0;
cout << "The sum of the elements: ";
for (int i = 0; i < number; i++)
sum += array[i];
cout << sum;
cout << endl;
}
void invert_Array(double array[], int number)
{
double temp = 0;
cout << "The reverse array is: " << temp;
for (int i = 0; i < number / 2; i++)
{
temp += array[i];
array[i] = array[number - i - 1];
array[number - i - 1] = temp;
}
cout << endl;
}
void max_Array(double array[], int number)
{
double max = 0;
cout << "The biggest number is: ";
for (int i = 0; i < number; i++)
{
if (number > array[i])
array[i] = max;
cout << max;
cout << endl;
}
}
|