题解 | #牛牛的书#
牛牛的书
https://www.nowcoder.com/practice/30bb969e117b4f6d934d4b60a2af7489
#include<stdio.h> typedef struct d { char a[20]; int sore; } book; void sort(book* s, int n) { for (int i = 0; i < n; i++) { for (int j = 0; j < n - 1 - i; j++) { if (s[j].sore > s[j + 1].sore) { book temp = s[j]; s[j] = s[j + 1]; s[j + 1] = temp; } } } } int main() { book s[100]; int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%s%d", s[i].a, &(s[i].sore)); } sort(s, n); for (int i = 0; i < n; ++i) { printf("%s\n", s[i].a); } return 0; }