#28673: CPP


(unknown)

School : No School
ID : 0
IP address : []
Last Login :
2023-03-28 03:55:27
a915. 二维点排序 | From: [219.85.177.13] | Post Date : 2021-12-25 23:02

#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
pii p[100001];

bool cmp(pii i, pii j){
if (i.first==j.first){
return i.second<j.second;
}
else {
return i.first<j.first;
}
}

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
while (cin >> n){
for (int i=0; i<n; i++){
cin >> p[i].first >> p[i].second;
}
sort(p, p+n, cmp);
for (int i=0; i<n; i++){
cout << p[i].first <<" "<< p[i].second <<endl;;
}
}
}
 
ZeroJudge Forum