题解 | #牛牛的书#
牛牛的书
https://www.nowcoder.com/practice/30bb969e117b4f6d934d4b60a2af7489
#include <stdio.h> struct book{ char name[20]; float price; }; int main() { int n; scanf("%d", &n); struct book b[n]; for(int i = 0; i < n; i++){ scanf("%s %f", b[i].name, &b[i].price); } // 选择排序 for(int i = 0; i<n; i++){ int min = i; for(int j = i; j<n; j++){ if(b[j].price < b[min].price) min = j; } printf("%s\n", b[min].name); struct book t = b[i]; b[i] = b[min]; b[min] = t; } return 0; }