```c #include <stdio.h> #include <string.h> struct student { char no[10]; char name[10]; float score; }; // 交换两个学生结构体的函数 void swap(struct student *a, struct student *b) { struct student temp = *a; *a = *b; *b = temp; } // 冒泡排序函数 void bubbleSort(struct student arr[], int n) { int i, j; for (i = 0; i < n - 1; i++) { for (j = 0; j < n - i - 1; j++) { if (arr[j].score > arr[j + 1].score) { swap(&arr[j], &arr[j + 1]); } } } } int main() { struct student students[5]; int i; for (i = 0; i < 5; i++) { printf("请输入第%d位同学的信息:姓名 学号 成绩\n", i + 1); scanf("%s%s%f", students[i].name, students[i].no, &students[i].score); } bubbleSort(students, 5); for (i = 0; i < 5; i++) { printf("%s,%s,%.0f\n", students[i].name, students[i].no, students[i].score); } return 0; } ``` [2024-10-30 18:45:58 | AI写代码神器 | 354点数解答]