提交时间:2023-08-23 09:49:54
运行 ID: 99547
#include<bits/stdc++.h> using namespace std; int a[10005], b[10005]; int main(){ int n; cin >> n; for (int i = 1; i <= n; i++){ cin >> a[i] >> b[i]; } for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ if (a[i] > a[j]){ swap(a[i], a[j]); swap(b[i], b[j]); } else if (a[i] == a[j]){ if (b[i] > b[j]){ swap(a[i], a[j]); swap(b[i], b[j]); } else { continue; } } } } for (int i = 1; i <= n; i++){ cout << a[i] << " " << b[i] << endl; } }