void MergeArray(int cry[],int temp[],int begin,int middle,int end)
{
int i=begin;
int j=middle+1;
int k=i;
while(i<=middle&&j<=end)
{
if(cry[i]<=cry[j])
{
temp[k]=cry[i];
i++;
}
else
{
std::cout<<"["<<i<<","<<j<<"]:"<<cry[i]<<" "<<cry[j]<<endl;
temp[k]=cry[j];
j++;
}
k++;
}
while(i<=middle)
{ temp[k]=cry[i];
i++;
k++;
}
while(j<=end)
{
temp[k]=cry[j];
k++;
j++;
}
for(int m=begin;m<=end;++m)
cry[m]=temp[m];
}
void Merge(int cry[],int temp[] ,int begin,int end)
{
if(begin<end)
{
int middle=(begin+end)/2;
Merge(cry,temp,begin,middle);
Merge(cry,temp,middle+1,end);
MergeArray(cry,temp,begin,middle,end);
}
}
void MergeSort(int cry[],int N)
{
int* temp=new int[N]();
Merge(cry,temp,0,N-1);
delete[]temp;
}
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }