[题目分析] 题目要求调整后第一数组(A)中所有数均不大于第二个数组(B)中所有数因两数组分别有序这里实际是要求第一数组的最后一个数A[m]不大于第二个数组的第一个数B[]由于要求将第二个数组的数插入到第一个数组中因此比较A[m]和B[]如A[m]>B[]则交换交换后仍保持A和B有序重复以上步骤直到A[m]<=B[]为止
void ReArranger (int A[]B[]mn)
//A和B是各有m个和n个整数的非降序数组本算法将B数组元素逐个插入到A中使A中各元素均不大于B中各元素且两数组仍保持非降序排列
{ while (A[m]>B[])
{x=A[m];A[m]=B[]; //交换A[m]和B[]
j=;
wkile(j<n && B[j]<x) B[j]=B[j++]; //寻找A[m]的插入位置
B[j]=x;
x=A[m];i=m;
wkile(i>= && A[i]>x) A[i+]=A[i]; //寻找B[]的插入位置
A[i+]=x;
}
}算法结束
[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []