|
板凳
楼主 |
发表于 2017-10-5 09:06:16
|
只看该作者
[mw_shl_code=c,true]#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[6];
int i;
int temp;
int j;
for(i=1;i<=5;i++)//将5个倒霉蛋的成绩存入数组
{
printf("请输入第%d个熊孩子的成绩:",i);
scanf("%d",&a);
}
for(j=1;j<=5;j++)
{
for(i=j+1;i<=5;i++)//楼主的疏忽,a[0]这一位没用上,从a[1]开始了
{
if(a[j]<=a){temp=a[j];a[j]=a;a=temp;}
}
}
printf("放牛班的成绩排序如下:");
for(i=0;i<=5;i++)
{
printf("%d ",a);
}
printf("\n");
system("pause");
return 0;
}
[/mw_shl_code] |
|