提交时间:2024-08-19 22:57:52

运行 ID: 168135

#include <iostream> using namespace std; int part(int a[], int low, int high) { int t; int pi=a[high]; int i=(low-1); for (int j=low; j<=high-1; j++) { if (a[j] <= pi) { i++; t=a[i]; a[i]=a[j]; a[j]=t; } } t=a[i+1]; a[i+1]=a[high]; a[high]=t; return (i + 1); } void qSort(int a[], int low, int high) { if (low < high) { int pi = part(a, low, high); qSort(a, low, pi-1); qSort(a, pi+1, high); } } int main() { int a[100001],n; cin>>n; for(int i=0;i<n;i++) { int b,c; cin>>b>>c; a[i]=10000*b+c; } qSort(a,0,n-1); for(int i=0;i<n;i++) { cout<<a[i]/10000<<" "<<a[i]%10000<<endl; } return 0; }