标签:stream class bsp oid std == cst ring lse
#include<iostream> #include<cstring> #define N 500+10 using namespace std; int a[N],s[N],n; void gb(int l,int r){ if(l==r)return; int m=(l+r)/2,tot=l-1,i=l,j=m+1; gb(l,m);gb(m+1,r); while(i<=m&&j<=r) if(a[i]>a[j])s[++tot]=a[j],j++; else s[++tot]=a[i],i++; while(i<=m)s[++tot]=a[i],i++; while(j<=r)s[++tot]=a[j],j++; for(int i=l;i<=r;i++) a[i]=s[i]; return; } int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>a[i]; gb(1,n); for(int i=1;i<=n;i++)cout<<a[i]<<" "; cout<<endl; return 0; }
标签:stream class bsp oid std == cst ring lse
原文地址:https://www.cnblogs.com/jzxnl/p/11070327.html