一个简单的程序,不知哪里出错了...请大家看看
#include<stdio.h>struct student{
int num;
char name[20];
int score;
};
struct student stud[10];
int main(void)
{
int i,j,index,sum=0;
struct student temp;
printf("\nInput the student's number,name and score:\n");
for(i=0;i<10;i++){
printf("No %d:",i+1);
scanf("%d%s%d",&stud[i].num,stud[i].name,&stud[i].score);
sum=sum+stud[i].score;
}
for(i=0;i<9;++i)
index=i;
for(j=i+1;j<10;j++)
if(stud[j].score<stud[index].score)
index=j;
temp=stud[index];
stud[index]=stud[i];
stud[i]=temp;
}
printf("The average:%d\n",sum/10);
printf("The student score:\n");
for(i=9;i>=0;i--)
printf("%d%s%d\n",stud[i].num,stud[i].name,stud[i].score);
return 0;
}
在VC6里运行有:1 error(s), 0 warning(s)
[ 本帖最后由 devotion 于 2009-8-6 22:30 编辑 ]