#include<iostream>
using namespace std;
//两个有序数组进行排序,A有足够的空间容纳B,把和A融入到一起
void MergeArr(int a[], int b[], int la, int lb)//输入A和B的数组和两个长度
{
if (la <= 0 || lb <= 0)
return;
int index=la+lb-1;
int ida = la - 1;
int idb = lb - 1;
while (index >= 0)
{
if (a[ida] > b[idb]||idb<0)
a[index--] = a[ida--];
else if (a[ida]<=b[idb]||ida<0)
a[index--] = b[idb--];
}
}
int main()
{
int a[10] = { 3, 5, 7, 10, 15 };
int b[] = { 4, 8, 16 };
MergeArr(a, b, 5, 3);
for (int i = 0; i < 3 + 5; i++)
{
cout << a[i] << endl;
}
return 0;
}