#include <iostream>
using namespace std;
const int N = 10;
const int MIN_NUM = -36767;
int SecondMax(int *a, int n){
if(a == NULL || n<=0)
return MIN_NUM;
int max = a[0];
int secmax = a[0];
if(n>1 && a[1] < a[0]){ //如果元素大于1,则选择前2个元素中较小的元素作为secmax
secmax = a[1];
}
for(int i=1;i<n;++i){
if(a[i] > max){
secmax = max;
max = a[i];
}else if(a[i] > secmax && a[i] != max){ //加a[i] != max,如果最大值不止一个,则不会更新secmax
secmax = a[i];
}
}
return secmax;
}
int main(int argc, char* argv[]){
int a[N];
for(int i=0;i<N;++i){
a[i] = 9;
a[1] = 10;
cout<<a[i]<<" ";
}
cout<<endl<<SecondMax(a, N)<<endl;
return 0;
}