思路:直接sort排序,输出倒数第二个~
这题目感觉有点坑啊,如果最大数和第二大数相同,还是输出第二大数。。可能我想多了吧。。
代码:
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
int main()
{
LL a[25], ans;
int num=0;
while(1)
{
LL t;
scanf("%I64d", &t);
if(t==0)break;
else a[num] = t;
num++;
}
sort(a, a+num);
printf("%I64d", a[num-2]);
return 0;
}
原文地址:http://blog.csdn.net/u014355480/article/details/41727615