一:忘记i++ ,j++
#include<cstdio>
using namespace std;
const int N=100005;
int a[N] ,tmp[N];
void merge_sort(int q[],int l,int r){
if(l>=r){
return;
}
int mid=l+r>>1;
merge_sort(q,l,mid);
merge_sort(q,mid+1,r);
int i=l,j=mid+1,k=0;
while(i<=mid&&j<=r){
if(q[i]<q[j]){//在此加不加等号都一样.
tmp[++k]=q[i];
i++;
}else{
tmp[++k]=q[j];
j++;
}
}
while(i<=mid){
tmp[++k]=q[i];
i++;//忘记了
}
while(j<=r){
tmp[++k]=q[j];
j++;//忘记了
}
for(i=l,j=1;i<=r;i++,j++){
q[i]=tmp[j];
}
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
merge_sort(a,1,n);
for(int i=1;i<=n;i++){
printf("%d ",a[i]);
}
return 0;
}