#include
<
iostream
>
using namespace std;
int a[ 25 ] = ... {-2,-3,0,0,1,2,3,5,6,9,29,90,78,343,2,3,5,-90,12,7,9,8,34,33,12} ;
void secMax( int beg, int end, int & max, int * secList, int & len)
... {//beg,end用来访问数组中数据,max,secList是要返回的结果,len是secList的长度
if(end==beg)...{
max=a[end];
len=0;
return;
}
if(end==beg+1)...{
if(a[beg]>a[end])...{
max=a[beg];
len=1;
secList[len-1]=a[end];
}
else...{
max=a[end];
len=1;
secList[len-1]=a[beg];
}
return;
}
int max1,max2,i;
int n1,n2,len1,len2;
int list1[6],list2[6];
n1=(end-beg+1)/2,n2=(end-beg+1)-n1;
secMax(beg,beg+n1-1,max1,list1,len1);
secMax(beg+n1,end,max2,list2,len2);
if(max1>max2)...{
max=max1;
len=len1+1;
for(i=0;i<len-1;i++)
secList[i]=list1[i];
secList[len-1]=max2;
}
else...{
max=max2;
len=len2+1;
for(i=0;i<len-1;i++)
secList[i]=list2[i];
secList[len-1]=max1;
}
}
void main()
... {
int max,maxSec,secList[6],len,i;
secMax(0,24,max,secList,len);
maxSec=secList[0];
for(i=1;i<len;i++)...{
if(maxSec<secList[i])
maxSec = secList[i];
}
cout<<max<<" "<<maxSec<<endl;
}
using namespace std;
int a[ 25 ] = ... {-2,-3,0,0,1,2,3,5,6,9,29,90,78,343,2,3,5,-90,12,7,9,8,34,33,12} ;
void secMax( int beg, int end, int & max, int * secList, int & len)
... {//beg,end用来访问数组中数据,max,secList是要返回的结果,len是secList的长度
if(end==beg)...{
max=a[end];
len=0;
return;
}
if(end==beg+1)...{
if(a[beg]>a[end])...{
max=a[beg];
len=1;
secList[len-1]=a[end];
}
else...{
max=a[end];
len=1;
secList[len-1]=a[beg];
}
return;
}
int max1,max2,i;
int n1,n2,len1,len2;
int list1[6],list2[6];
n1=(end-beg+1)/2,n2=(end-beg+1)-n1;
secMax(beg,beg+n1-1,max1,list1,len1);
secMax(beg+n1,end,max2,list2,len2);
if(max1>max2)...{
max=max1;
len=len1+1;
for(i=0;i<len-1;i++)
secList[i]=list1[i];
secList[len-1]=max2;
}
else...{
max=max2;
len=len2+1;
for(i=0;i<len-1;i++)
secList[i]=list2[i];
secList[len-1]=max1;
}
}
void main()
... {
int max,maxSec,secList[6],len,i;
secMax(0,24,max,secList,len);
maxSec=secList[0];
for(i=1;i<len;i++)...{
if(maxSec<secList[i])
maxSec = secList[i];
}
cout<<max<<" "<<maxSec<<endl;
}