#include
#define N 5
struct student
{
int num;
char name[9];
float math;
float english;
float physics;
float sum;
};
typedef struct student STU;
int main()
{
int i,j;
STU st[N],ST;
for (i=0;i
{
printf("请输入第个%d学生的学号:",i+1);
scanf("%d",&st[i].num);
getchar();
printf("请输入第个%d学生的姓名:",i+1);
gets(st[i].name);
printf("请输入第个%d学生的数学成绩:",i+1);
scanf("%f",&st[i].math);
printf("请输入第个%d学生的英语成绩:",i+1);
scanf("%f",&st[i].english);
printf("请输入第个%d学生的物理成绩:",i+1);
scanf("%f",&st[i].physics);
}
for (i=0;i
st[i].sum=st[i].math+st[i].english+st[i].physics;
for (j=0;j
for (i=0;i
{
if (st[i].sum
{
ST=st[i];
st[i]=st[i+1];
st[i+1]=ST;
}
}
printf("学号\t姓名\t数学\t英语\t物理\t总分\n");
for (i=0;i
{
printf("%d\t",st[i].num);
printf("%s\t",st[i].name);
printf("%0.1f\t",st[i].math);
printf("%0.1f\t",st[i].english);
printf("%0.1f\t",st[i].physics);
printf("%0.1f\n",st[i].sum);
}
return 0;
}