题解 | #特殊排序#
小白鼠排队
http://www.nowcoder.com/practice/27fbaa6c7b2e419bbf4de8ba60cf372b
//类似成绩排序,定义函数更简单一些 #include<iostream> #include<algorithm> using namespace std; struct mouse { int weight; char color[10]; }; bool compare(mouse x,mouse y) { if(1) { return x.weight>y.weight; } } int main() { mouse stu[100]; int n; while(scanf("%d",&n)!=EOF) { for(int i=0; i<n; i++) { scanf("%d %s",&stu[i].weight,&stu[i].color); } sort(stu,stu+n,compare); for(int i=0; i<n; i++) { printf("%s\n",stu[i].color); } } return 0; }