#include <iostream> #include <algorithm> using namespace std; struct Student{ int num; int grade; }; bool cmp(Student lhs, Student rhs){ if(lhs.grade == rhs.grade) return lhs.num<rhs.num; else{ return lhs.grade < rhs.grade; } } int main() { Student arr[110]; int n; scanf("%d",&n); for(int i=0; i<n; ++i){ scanf("%d%d",&arr[i].num,&arr[i].grade); } sort(arr,arr+n,cmp); for(int i=0;i<n;++i){ printf("%d %d\n",arr[i].num,arr[i].grade); } // int a, b; // while (cin >> a >> b) { // 注意 while 处理多个 case // cout << a + b << endl; // } } // 64 位输出请用 printf("%lld")