# include
struct student
{
int age;
double score;
char name[30];
};
int main(void)
{
struct student * p, t;
int len, i, j;
printf("输入学生个数:");
printf("len=");
scanf_s("%d", &len);
p = (struct student *)malloc(len * sizeof(struct student));
for (i = 0; i < len; ++i)
{
printf("输入第%d学生的信息:\n", i+1);
printf("输入学生年龄:");
scanf_s("%d", &p[i].age);
printf("输入学生成绩:");
scanf_s("%lf", &p[i].score);
printf("输入学生姓名:");
scanf_s("%s", (p + i)->name);
}
printf("\n\n");
for (i = 0; i < len - 1; ++i)
{
for (j = 0; j < len - 1 - i;++j)
if (p[j].score > p[j + 1].score)
{
t = p[j];
p[j] = p[j + 1];
p[j + 1] = t;
}
}
for (i = 0; i < len; ++i)
{
printf("第%d个学生的信息是:\n\n", i+1);
printf("年纪是%d\n\n", p[i].age);
printf("分数是%lf\n\n", p[i].score);
printf("姓名是%s\n\n\n\n", p[i].name);
}
return 0;
}