提交时间:2023-08-23 10:39:24

运行 ID: 99567

#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 i = 0;i <n-1;i++){ 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; }