标签:
1 void merge(vector<int>& A, vector<int>& B, int m, int n) 2 { 3 int indexA = m - 1, indexB = n - 1, index = m + n - 1; 4 while (index >= 0) { 5 while (indexA >= 0 && indexB >= 0) { 6 if (A[indexA] >= B[indexB]) { 7 A[index --] = A[indexA--]; 8 } 9 else { 10 A[index --] = B[indexB--]; 11 } 12 } 13 //while (indexA >= 0) A[index--] = A[indexA--]; 14 while (indexB >= 0) A[index--] = B[indexB--]; 15 } 16 }
标签:
原文地址:http://www.cnblogs.com/shadowwalker9/p/5858651.html