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 90 91 92
|
#include <iostream>
using namespace std;
const int Max_Size = 20; // Determines size of array and number of intergers, Do not exceed 20!
void showMenu(); // displays the menu for the program
void getUserList(int a[], int size); //will get the numbers from user and put into an array making the list
void showReverseList(int a[], int size); //function will reverse the numbers given from the array list and display them on the console
void getMax(int a[], int size); //gets biggest value from array
void getMin(int a[], int size); //gets smallest value from array
int main()
{
int UserNum[Max_Size];
showMenu();
getUserList(UserNum, Max_Size);
cout << "Numbers in reverse order" << endl;
showReverseList(UserNum, Max_Size);
getMax(UserNum, Max_Size);
getMin(UserNum, Max_Size);
return 0;
}
void showMenu()
{
cout << "------------------------------------------------------------------------" << endl;
cout << "Enter up to " << Max_Size << " Integers and I will display them in reverse order!" << endl;
cout << "Press 0 to end the list" << endl;
cout << "------------------------------------------------------------------------" << endl;
}
void getUserList(int a[], int size)
{
for (int index = 0; index < size; index++)
{
cin >> a[index];
}
}
void showReverseList(int a[], int size)
{
for (int index = size-1; index >= 0; index--)
{
cout << a[index] << endl;
}
}
void getMax(int a[], int size)
{
int Max;
Max = a[0];
for (int i = 1; i < size; i++)
{
if (a[i] > Max)
{
Max = a[i];
}
}
cout << "The Biggest Integer of the list is: " << Max << endl;
}
void getMin(int a[], int size)
{
int Min;
Min = a[0];
for (int i = 1; i < size; i++)
{
if (a[i] < Min)
{
Min = a[i];
}
}
cout << "The Smallest Integer of the list is: " << Min << endl;
}
| |