int max(int *array, int len)
{
  int n1,n2;
  if(len == 1) return array[0] ;


  n1 = max(array , len/2);
  n2 = max(array + len/2 , len - len/2) ;
  return (n1 > n2 ? n1 : n2) ;
}


int main()
{
   int A[] = {2,7,91,8,9,11} ;
   int B[] = {2,7,91,8,9} ;

   printf("\n%d ",max(&A[0], 6));
   printf("\n%d\n ",max(&B[0], 5));
}
3
Contributors
3
Replies
5
Views
12 Years
Discussion Span
Last Post by sweetleaf
0

dude u do not need to pass &a[0] as parameter simply the name of the array serves as the address of the first element

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.