vector<int> mergeSortedArray(vector<int> &A, vector<int> &B) { int main(){ vector<int> A = {1, 2, 3, 4}; vector<int> B = {2, 4, 5, 6}; print_vector<int>(mergeSortedArray(A,B)); return 0; }
//测试程序 void main() { int LA[5]={1,2,3,4,5}; int LB[5]={1,7,8,9,10}; struct array mergedArray; mergedArray = mergeSortedArray(LA,5,LB,5); int i; for(i=0;i<mergedArray.len;i++) printf("%d ",mergedArray.starter[i]); printf("\n"); }
void merge(int array[], int left, int right, int temp[]){ if (left == right){ return; }else{ int mid = (left + right) / 2; merge(array, left, mid, temp); merge(array, mid + 1, right, temp); mergeSortedArray(array, left, mid, right, temp); } }