标签:main style pre lse printf 最大 else std pause
找出最大和第二大值
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int mynum[] = {43, 88, 56, 24, 78, 12, 8,29,57,80};
int max=0;
printf("%d\n", max);
int smax=0;
printf("%d\n", smax);
if (mynum[0] > mynum[1])
{
max = mynum[0];
smax = mynum[1];
}
else
{
max = mynum[1];
smax = mynum[0];
}
for (int i = 2; i < 10; i++)
{
if (max < mynum[i])
{
smax = max;
max = mynum[i];
}
else if ((mynum[i]<max) && (mynum[i]>smax))
{
smax = mynum[i];
}
}
printf("%d\n",max);
printf("%d\n", smax);
system("pause");
}
标签:main style pre lse printf 最大 else std pause
原文地址:https://www.cnblogs.com/saintdingspage/p/10338577.html