回复 20# 的帖子
#define INT_MAX 0x7FFF#define INT_MIN ((int)0x8000)
去头文件看了下``原来真的有耶``mqh21364非常感谢
现在仔细看了下```是我错了。。。t2有定义
void swap(int* arr,int i,int j) { int temp=arr[i]; arr[i] = arr[j]; arr[j] = temp; } int partition(int*arr,int l,int r) { int j=r,key=arr[l]; int i=l; for(++i;i<j;) { for(;arr[i]<key;++i); for(;arr[j]>key;--j); if(i<j) swap(arr,i,j); } swap(arr,j,l); return j; } int SelectPartition(int* arr,int l,int r,int p) { int j=-1,m=-1; for(;m!=p; ) { if(arr[l]==arr[r]) return arr[l]; j=partition(arr,l,r); m=j-l+1; if(m<p) { l=j+1; p=p-j; } else r=j-1; } return arr[j]; } void FindMaxMin(int nList[],int nLen) { cout<<"Mixmum: "<<SelectPartition(nList,0,nLen-1,nLen)<<endl; cout<<"Manmum: "<<SelectPartition(nList,0,nLen-1,1)<<endl; }