给你一个提示
# include
# include
struct student
{
int age;
float score;
char name[100];
};
int main(void)
{
int len;
struct student *pArr;
int i;
int a, b;
struct student t;
printf("请输入学生的个数:\n");
printf("len = ");
scanf("%d",&len);
pArr = (struct student *)malloc(len *sizeof(struct student));
for (i=0; i
printf("请输入第%d个学生的信息:\n", i+1);
printf("age = ");
scanf("%d",&pArr[i].age);
printf("score =");
scanf("%f",&pArr[i].score);
printf("name = ");
scanf("%s", pArr[i].name);
}
for (a=0; i
for (b=0; b
if(pArr[b].score > pArr[b+1].score) // > 升序 ,< 降序
{
t = pArr[b];
pArr[b] = pArr[b+1];
pArr[b+1] = t;
}
}
}
// 输出
printf("\n\n学生的信息是\n");
for (i=0; i
printf("第%d个学生的信息:", i+1);
printf("age = %d\n",pArr[i].age);
printf("score =%f\n",pArr[i].score);
printf("name = %d\n",pArr[i].name);
printf("\n");
}
return 0;
}
好长啊