提交时间:2023-08-23 10:40:17

运行 ID: 99568

#include<bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); int ai[10001]; int bi[10001]; for(int i = 0;i < n;i++){ scanf("%d %d",&ai[i],&bi[i]); } for(int i = 0;i < n;i++){ for(int j = 0;j <n-1;j++){ if(ai[i] > ai[i+1]){ int tmp; tmp =ai[i]; ai[i] = ai[i+1]; ai[i+1] = tmp; tmp =bi[i]; bi[i] = bi[i+1]; bi[i+1] = tmp; }else if(ai[i] == ai[i+1] && bi[i] > bi[i+1]){ int tmp; tmp =ai[i]; ai[i] = ai[i+1]; ai[i+1] = tmp; tmp =bi[i]; bi[i] = bi[i+1]; bi[i+1] = tmp; } } } for(int i = 0;i < n;i++){ printf("%d %d\n",ai[i],bi[i]); } return 0; }