好嘞
嘻嘻[此贴子已经被作者于2019-6-19 11:45编辑过]
#include <stdio.h> struct person { int num; char name[20]; double score; } student[5] = {{140602215, "zhang", 89.5}, {140602216, "li", 45}, {140602217, "wang", 78}, {140602218, "zhao", 67}, {140602219, "ru", 90} }; int main(void) { int i, j; struct person temp; for(i = 0; i < 4; i++) { for(j = i+1; j < 5; j++) if(student[i].score > student[j].score) { temp = student[i]; student[i] = student[j]; student[j] = temp; } } for(i = 0 ; i < 5; i++) { printf("%d\t%s\t%0.1f\n", student[i].num, student[i].name, student[i].score); } return 0; }