这程序为什么没有出结果啊??
#include<iostream.h>
struct point //定义一个结构体用来存放x,y
{
int x;
int y;
};
point MinMax(int A[], int low, int high) //寻找最大和最小元素
{
point p,p1,p2;
if((high -low) == 1)
{
if(A[high] > A[low])
{
p.x = A[low];
p.y = A[high];
return p;
}
else
{
p.x = A[high];
p.y = A[low];
return p;
}
}
else
{
int mid = (high - low)/2;
p1 = MinMax(A, low, mid);//递归调用
p2 = MinMax(A, mid+1, high);
if(p1.x > p2.x)
{
p.x = p2.x;
}
if(p1.x < p2.x)
{
p.x = p1.x;
}
if(p1.y > p2.y)
{
p.y = p1.y;
}
if(p1.y < p2.y)
{
p.y = p2.y;
}
return p;
}
}
void main()
{
point p3;//定义一个point类型的变量,用于接收返回值
int a[10]={1,23,24,1,6,23,34,2,54,6};
p3 = MinMax(a,0,9);
cout<<p3.x<<" "<<p3.y<<endl;
}