题解 | #争夺前五名#
争夺前五名
http://www.nowcoder.com/practice/cd052308a1c44a88ad00255f312c3e14
include<stdio.h>
int main()
{
int num = 0;
int n = 0;
int k = 0;
int arr[10] = { 0 };
scanf("%d", &num);
for (n = 1; num >= n; n++)
{
int scord = 0;
int i = 0;
scanf("%d", &scord);
arr[n] = scord;//调试的检验时候出了大问题,越线了
for (i = n; arr[i - 1] < arr[i]; i--)
{
int c = 0;
c = arr[i - 1];
arr[i - 1] = arr[i];
arr[i] = c;
if (i == 1)
i++;
}
}
for (k = 0; k < 5; k++)
printf("%d ", arr[k]);
return 0;
}