#include
#include
int max;
int min;
void maxmin(int[],int,int);
void main()
{
clrscr();
int a[50],x,i;
cout<<"Enter the size of the array::";
cin>>x;
cout<
cin>>a[i];
maxmin(a,1,x);
cout<
}
void maxmin(int a[],int i,int j)
{
if(i==j)
{
max=a[i];
min=a[i];
}
else
{
if(i==(j-1))
{
if(a[i]>a[j])
{
max=a[i];
min=a[j];
}
else
{
max=a[j];
min=a[i];
}
}
else
{
int mid=floor((i+j)/2);
maxmin(a,i,mid);
int max1=max;
int min1=min;
maxmin(a,mid+1,j);
if(max1>max)
max=max1;
if(min1
}
}
}
No comments:
Post a Comment