这是递归代码
void MERGE(vector<int>::iterator ite, int left, int right, int mid){ // if (left == right)return; // else{ // MERGE(ite, left, mid, (left + mid) / 2); MERGE(ite, mid + 1, right, (mid + 1 + right) / 2); // vector<int>v1(ite + left, ite + mid); vector<int>v2(ite + mid + 1, ite + right); int i = 0, j = 0; while (i != v1.size() && j != v2.size()){ if (v1[i] < v2[j]){ *(ite + left + i + j) = v1[i++]; } else{ *(ite + left + i + j) = v2[j++]; } } if (i == v1.size()){ while (j != v2.size()){ *(ite + left + i + j) = v2[j++]; } } else{ while (i != v1.size()){ *(ite + left + i + j) = v1[i++]; } } return; } }