这是我想要做的一个例子:
int size = 10;
int *data = new int[size];
int *array_1 = &data[0];
int *array_2 = &data[size/2];
//fill array_1 and array_2 with data
sort(array_1, array_1+size/2);
sort(array_2, array_2+size/2);
//now, is it possible to merge the 2 sorted arrays?
例如,array_1 = {1, 4, 7}
和array_2 = {3, 5, 6}
我正在尝试制作data = {1, 3, 4, 5, 6, 7}
答案 0 :(得分:1)
你想要std :: inplace_merge。见http://www.cplusplus.com/reference/algorithm/inplace_merge/