chillurbrain

Task7_7_1

Dec 21st, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <conio.h>
  4.  
  5. using namespace std;
  6.  
  7. int* findMax(int *arr, int size)
  8. {
  9.     int* start = arr;
  10.     int* max = start;
  11.     while(start != arr + size)
  12.     {
  13.         if(*start > *max)
  14.             max = start;
  15.         start++;
  16.     }
  17.     return max;
  18. }
  19.  
  20. int main()
  21. {
  22.     const int SIZE = 5;
  23.     int array[SIZE];
  24.     for(int i = 0; i < 5; i++)
  25.         cin >> array[i];
  26.     cout << *findMax(array, SIZE);
  27.     _getch();
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment