#include<bits/stdc++.h>
using namespace std;
//归并排序
/*
void conquer(int l,int m,int r,int a[],int len){
int b[len];
for(int i=0;i<len;i++)
b[i] = a[i];
int i=l,j=m+1,k=l;
while(i<=m&&j<=r){
if(b[i]<b[j]){
a[k++] = b[i++];
}else{
a[k++] = b[j++];
}
}
if(i>m){
for(;j<=r;j++)
a[k++] = b[j];
}else{
for(;i<=m;i++)
a[k++] = b[i];
}
}
void divide(int l, int r, int a[],int len){
if(l==r||r-l==1){
if(a[l]>a[r]) swap(a[l],a[r]);
return ;
}
int m = (l+r)/2;
divide(l,m,a,len);
divide(m+1,r,a,len);
conquer(l,m,r,a,len);
}
void merge_sort(int a[], int len){
divide(0,len-1,a,len);
}
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
merge_sort(a,n);
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/
//希尔排序
/*
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
int temp;
for(int step=n/2;step>0;step/=2){
for(int i=step;i<n;i+=step){
int temp = a[i],j;
for(j=i-step;j>=0&&a[j]>temp;j-=step){
a[j+step] = a[j];
}
a[j+step] = temp;
}
}
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/
//插入排序
/*
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
int temp;
for(int i=1;i<n;i++){
int temp = a[i];
int j;
for(j=i-1;j>=0&&a[j]>temp;j--){
a[j+1] = a[j];
}
a[j+1] = temp;
}
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/
//选择排序
/*
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
int temp;
int minn,cur;
for(int i=0;i<n;i++){
minn = a[i],cur = i;
for(int j=i;j<n;j++){
if(a[j]<=minn){
minn = a[j];
cur = j;
}
}
temp = a[i];
a[i] = a[cur];
a[cur] = temp;
}
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/
//冒泡排序
/*
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
int temp;
for(int i=0;i<n-1;i++){
for(int j=0;j<n-1-i;j++){
if(a[j]>a[j+1]){
temp = a[j],a[j]=a[j+1],a[j+1] = temp;
}
}
}
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/
//快速排序
/*
void quick_sort(int a[],int l,int r){
if(l>=r)
return;
int temp = a[l], i=l,j=r;
while(i<j){
while(a[j]>temp&&i<j){
j--;
}
while(a[i]<=temp&&i<j){
i++;
}
if(i<j){
swap(a[i],a[j]);
}
}
a[l] = a[j];
a[j] = temp;
quick_sort(a,l,j-1);
quick_sort(a,j+1,r);
}
int main(){
int a[] = {10,5,2,4,9,23,10,4,7,21};
int n=10;
int temp;
quick_sort(a,0,n-1);
for(int i=0;i<n;i++)
printf("%d ",a[i]);
printf("\n");
}
*/