#28673: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
a915. 二维点排序 | From: [219.85.177.13] | 發表日期 : 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