各位大神,可以帮我说明一下我该怎样修改吗?(学生管理简易系统)
#include <stdio.h>#include<malloc.h>
struct student
{
char name[100];
int age;
float score;
};
void inputstudent(struct student * pss,int len)
{
int i;
for(i=0;i<len;++i)
{
printf("请输入第%d名学生的信息:\n",i+1);
printf("name=");
scanf("%s\n",&pss[i].name);
printf("age=");
scanf("%d\n",&pss[i].age);
printf("score=");
scanf("%f\n",&pss[i].score);
}
}
void sort(struct student * st,int len)
{
int i,j;
struct student t;
for(i=0;i<len-1;++i)
{
for(j=0;j<len-1-i;++j)
{
if(st[j].score>st[j+1].score)
{ t=st[j];
st[j]=st[j+1];
st[j+i]=t;
}
}
}
}
void outputstudent(struct student * su,int len)
{
int j;
for(j=0;j<len;++j)
{
printf("name=%s",su[j].name);
printf("name=%d",su[j].age);
printf("name=%f",su[j].score);
}
}
int main(void)
{
int len;
struct student * s;
printf("请输入学生的个数:\n");
printf("len=");
scanf("%d",&len);
s=(struct student *)malloc(len*sizeof(struct student));
inputstudent(s,len);
sort(s,len);
outputstudent(s,len);
return 0;
}