提交时间:2023-08-23 13:58:34

运行 ID: 99628

#include<iostream> #include<cmath> 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] && b[i] > b[j]){ swap(a[i], a[j]); swap(b[i], b[j]); } } } for (int i = 1; i <= n; i++) cout << a[i] << " " << b[i] << endl; return 0; }