提交时间:2023-12-13 13:33:08

运行 ID: 115742

#include<bits/stdc++.h> using namespace std; int n; struct node { int a,b; }; bool cmp(node a,node b) { return (a.a!=b.a?a.a<b.a:a.b<b.b); } int main() { cin>>n; struct node *ab=new node[n+1]; for(int i=1;i<=n;i++) cin>>ab[i].a>>ab[i].b; sort(ab+1,ab+n+1,cmp); for(int i=1;i<=n;i++) cout<<ab[i].a<<' '<<ab[i].b<<'\n'; delete[] ab; }