1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-12-16 15:44:39 +00:00
202401-programming-assignments/【实践课外】15.结构体1/6-4 利用“选择排序算法“对结构体数组进行排序.c

18 lines
256 B
C
Raw Permalink Normal View History

2024-12-11 03:41:51 +00:00
p = p1;
for (p2 = p1 + 1; p2 < pData + n; p2++) {
if (p2->score > p->score) {
p = p2;
}
}
if (p != p1) {
num = p->num;
p->num = p1->num;
p1->num = num;
score = p->score;
p->score = p1->score;
p1->score = score;
}