题解 | #小白鼠排队#
小白鼠排队
https://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
#include<cstdio> #include<iostream> #include<algorithm> using namespace std; typedef struct mouse{ int weight; char color[100]; }mouse; bool com(mouse left,mouse right) { if(left.weight>right.weight) return true; else return false; } int main() { mouse m[1000]; int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d %s",&m[i].weight,m[i].color); } sort(m,m+n,com); for(int i=0;i<n;i++) { printf("%s\n",m[i].color); } }
easy