标签:cpp amp ace ges include return cout div name
#include <bits/stdc++.h> using namespace std; void mergesort(int a[],int l,int r){ int mid=(l+r)/2,i,j,k,c[r-l+10]; if(l==r)return; mergesort(a,l,mid);mergesort(a,mid+1,r); i=l;j=mid+1;k=0; while(i<=mid&&j<=r){ if(a[i]<a[j])c[k++]=a[i++]; else c[k++]=a[j++]; } while(i<=mid)c[k++]=a[i++]; while(j<=r)c[k++]=a[j++]; for(int i=l;i<=r;i++)a[i]=c[i-l]; } int main(){ int n,a[1000]; cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; mergesort(a,1,n); for(int i=1;i<=n;i++)cout<<a[i]<<‘ ‘; puts(""); return 0; }
标签:cpp amp ace ges include return cout div name
原文地址:http://www.cnblogs.com/HC-LittleJian/p/7659352.html