#include#include int main() { int N = 0; //创建结构体 printf("学生成绩排序n"); struct student { char name[10]; int id; int score; int stuspace; }; struct student students[10]; struct student stuspace;//定义结构体变量 //输入学生信息 for (N = 0;N < 10;N++) { scanf("%s %d %d", students[N].name, &students[N].id, &students[N].score);//依次输入姓名,学号,分数 } for (N = 0; N < 10; N++) { for (int M = 0; M < 9 - N; M++) { if (students[N].score > students[N + 1].score) { //对学生成绩表有高到低排序 stuspace = students[N];//stuspace为排序中的缓冲变量 students[N + 1] = students[N]; students[N] = stuspace; } } } //打印信 for (N = 0; N < 10; N++) printf("%s %d %dn", students[N].name, students[N].id, students[N].score); //因为只对数组的内容进行了改变,但姓名,学号,分数仍是一一对应的 }



