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
|
#include <iostream>
#include <iomanip>
using namespace std;
void getlist (int[], int &);
void putlist (const int [], int);
void reverse (const int [], int);
void EvenValues (const int[], int);
void GreaterThan (const int[], int);
const int MAXSIZE=25;
int main()
{
int list [MAXSIZE];
int num_items;
getlist (list, num_items);
putlist (list, num_items);
reverse (list, num_items);
EvenValues (list, num_items);
GreaterThan (list, num_items);
}
void getlist (int list [], int &num_items)
{
int i;
cout << "Please enter the number of array values ";
cin >> num_items;
for (i = 0; i < num_items; i++)
{
cout << "Enter the next array value " << endl;
cin >> list [i];
}
}
void putlist (const int list [], int num_items)
{
cout << "Array Elements" << endl;
for (int i = 0; i < num_items; i++)
cout <<i << " " << list [i] << endl;
}
void reverse (const int list [], int num_items)
{
cout << "Reverse Array Elements" << endl;
for (int i = num_items-1; i >= 0; i--)
cout <<i << " " << list [i] << endl;
}
void EvenValues (const int list [], int num_items)
{
cout << "Even Elements in the Array" << endl;
for (int i = 0; i< num_items; i++)
if (list [i]%2==0)
cout <<i<< " " <<list [i] << endl;
}
void GreaterThan (const int list [], int num_items)
{
cout <<"Array Elements in Numerical Order" << endl;
for (int i = 0; i < num_items; i++)
if (list [i]>list [i+1])
cout <<i<< " " <<list [i] << endl;
}
|