Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define max(a,b) (((a) > (b)) ? (a) : (b))
- int findMax( int * mas, int size )
- {
- if( size == 1 )
- return mas[0];
- return max( findMax( mas, size / 2 ), findMax( mas + size / 2, size - size / 2 ) );
- }
- int main()
- {
- const int N = 5;
- int ar[N] = { 2, 1, 5, 9, 3 };
- cout << "array: ";
- for( int i = 0; i < N; i++ )
- cout << ar[i] << ' ';
- cout << "nmax : " << findMax( ar, N ) << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment