标签:bit href art tar nbsp .net div c++ net
参考:https://blog.csdn.net/adusts/article/details/80882649
部分修改后代码:
1 #include<bits/stdc++.h> 2 using namespace std; 3 int a[10]; 4 void quick(int l,int r) 5 { 6 if (l>r) 7 return; 8 int temp=a[l],i=l,j=r; 9 while (i!=j) 10 { 11 while (a[j]>=temp&&i<j) 12 j--; 13 while (a[i]<=temp&&i<j) 14 i++; 15 if (i<j) 16 { 17 swap(a[i],a[j]); 18 } 19 } 20 a[l]=a[i]; 21 a[i]=temp; 22 quick(l,i-1); 23 quick(i+1,r); 24 } 25 int main() 26 { 27 int n; 28 cin>>n; 29 for (int i=1;i<=n;i++) 30 { 31 cin>>a[i]; 32 } 33 quick(1,n); 34 for (int i=1;i<=n;i++) 35 cout<<a[i]<<" "; 36 37 return 0; 38 }
标签:bit href art tar nbsp .net div c++ net
原文地址:https://www.cnblogs.com/hemeiwolong/p/10513187.html