Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***************************************/
- /** 20150402 Exam 05 **/
- /** Maker : Yan **/
- /** E-Mail : [email protected] **/
- /** Date : 2015/04/02 pm.12:00 **/
- /***************************************/
- #include <iostream>
- #include <iomanip>
- #include <limits.h>
- using namespace std;
- class numInsertAndGetMaximum{
- private:
- int numArray[100], numArrayCounter;
- public:
- void Initalize(){
- for(int i = 0; i < 100; i++)
- numArray[i] = EOF;
- numArrayCounter = 0;
- }
- void Insert(int number){
- numArray[numArrayCounter++] = number;
- return;
- }
- void ShowArray(){
- cout << "Array Element: ";
- for(int i = 0; i < numArrayCounter - 1; i++)
- cout << setw(3) << numArray[i];
- cout << endl;
- }
- int GetMaximum(){
- int tmpMax = INT_MIN;
- for(int i = 0; i < numArrayCounter; i++)
- if(numArray[i] > tmpMax)
- tmpMax = numArray[i];
- return tmpMax;
- }
- };
- int main(int argc, char const *argv[])
- {
- numInsertAndGetMaximum numFunction;
- numFunction.Initalize();
- int inNum = 0;
- while(inNum != EOF){
- cin >> inNum;
- numFunction.Insert(inNum);
- }
- numFunction.ShowArray();
- cout << "The maximum number int the array is: " << numFunction.GetMaximum() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment