显示的结果不对...求助
#include<stdio.h>struct info
{
int id;//学号
float score;//分数
};
int main() //按照分数大小排序输出
{
int i,j,k;
struct info a[3]={{10001,89.0},{10002,67.5},{10003,99.5}};
struct info b;
for(k=1;k<=2;k++)
{
for(i=0;i<2;i++)
{
if (a[i].score<a[i+1].score)
{
b.id=a[i].id;b.score=a[i].score;
a[i].id=a[i+1].id;a[i].score=a[i+1].score;
a[i+1].id=b.id;a[i+1].score=b.score;
}
}
}
for(j=0;j<=2;j++)
printf("%d\t%4.2f\n",a[j].id,a[i].score);
return 0;
}
结果显示:10003 67.5
10001 67.5
10002 67.5