#include<iostream>
using namespace std;
void main()
{
int a[]={3,6,2,3,1,3,1,9,3,7};
int onemax,secmax,thrmax;
onemax=secmax=thrmax=a[0];
for(int i=1;i<sizeof(a)/sizeof(a[0]);i++)
{
if(onemax<a[i])
{
secmax = onemax;
onemax = a[i];
}
else if(secmax<a[i])
{
thrmax = secmax;
secmax = a[i];
}
else if(thrmax<a[i])
{
thrmax = a[i];
}
}
cout<<onemax<<" "<<secmax<<" "<<thrmax<<endl;
}
乐其面试题-求数组的最大三个数
最新推荐文章于 2023-01-06 19:45:49 发布