歸並排序
#include "iostream.h"
using namespace std;
void merge(int A[], int Tmp[], int leftStart,int rightStart, int rightEnd){
int number = rightEnd-leftStart+1;
int leftEnd = rightStart-1;
int left=leftStart;
int right = rightStart;
int pos= leftStart;
while(left<=leftEnd&&right<=rightEnd){
if(A[left]<=A[right]){
Tmp[pos++]=A[left++];
}else{
Tmp[pos++]=A[right++];
}
}
while(left<=leftEnd){
Tmp[pos++]=A[left++];
}
while(right<=rightEnd){
Tmp[pos++]=A[right++];
}
int i=0;
//記得把Tmp拷回A,保證A有序
while(i>N;
for(int i=0;i>A[i];
}
mergeSort(A,N);
for(int i=0;i