寻找一维数组第二大的数据
#include<stdio.h>
int main()
{
int a[10] = {1412, 112, 34, 51, 17, 28, 10, 42, 131,3242}, i, max1, max2;
max1 = a[0];
max2 = a[0];
for(i = 1; i < 10; i++)
if(max1 < a[i])
max1 = a[i];
for(i = 1; i < 10; i++)
{
if(a[i] == max1)
continue;
if(max2 < a[i])
max2 = a[i];
}
printf("%d ", max2);
return 0;
}

2072

被折叠的 条评论
为什么被折叠?



