题解 | #小白鼠排队#
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include <stdio.h> #include <stdlib.h> #define N 110 typedef struct M{ int number; char color[12]; }Mouse; int cmp(const void *c1, const void* c2){ return ((Mouse*)c2)->number - ((Mouse*)c1)->number; } int main() { int n; Mouse mouse[N]; scanf("%d",&n); for(int i = 0;i < n;i ++){ scanf("%d%s",&mouse[i].number,mouse[i].color); } qsort(mouse,n,sizeof(mouse[0]),cmp); for(int i = 0;i < n;i ++){ printf("%s\n",mouse[i].color); } return 0; }