//用algorithm里面的sort函数 sort(数组起始地址,数组终止地址,(可自定义比较函数)) // 用一个结构体 #include<bits/stdc++.h> using namespace std; struct student{ int no; int score; }; bool compared(student st1,student st2){ if(st1.score==st2.score){ return st1.no<st2.no; }else{ return st1.score<st2.score; } }; int main(){ int N; cin>>N; student arr[N+1]; for(int i=1;i<=N;i++){ cin>>arr[i].no>>arr[i].score; } sort(arr+1,arr+N+1,compared); for(int i=1;i<=N;i++){ cout<<arr[i].no<<" "<<arr[i].score<<endl; } return 0; }