Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int* findMax(int *arr, int size)
- {
- int* start = arr;
- int* max = start;
- while(start != arr + size)
- {
- if(*start > *max)
- max = start;
- start++;
- }
- return max;
- }
- int main()
- {
- const int SIZE = 5;
- int array[SIZE];
- for(int i = 0; i < 5; i++)
- cin >> array[i];
- cout << *findMax(array, SIZE);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment