Guest User

Untitled

a guest
Feb 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #define max(a,b) (((a) > (b)) ? (a) : (b))
  2.  
  3. int findMax( int * mas, int size )
  4. {
  5. if( size == 1 )
  6. return mas[0];
  7.  
  8. return max( findMax( mas, size / 2 ), findMax( mas + size / 2, size - size / 2 ) );
  9. }
  10.  
  11. int main()
  12. {
  13. const int N = 5;
  14. int ar[N] = { 2, 1, 5, 9, 3 };
  15.  
  16. cout << "array: ";
  17. for( int i = 0; i < N; i++ )
  18. cout << ar[i] << ' ';
  19.  
  20. cout << "nmax : " << findMax( ar, N ) << endl;
  21.  
  22. return 0;
  23. }
Add Comment
Please, Sign In to add comment