更新时间:2022-11-08 17:39:56
在最后两个while
循环中,您的逻辑有误.
试试:
You have your logic wrong in the final twowhile
loops.
try:
while (x < nums.Length)
{
nums2[z] = nums[x];
z++;
x++;
}
while (y < nums1.Length)
{
nums2[z] = nums1[y];
z++;
y++;
}
顺便说一句:不要忘记在开始合并之前确保对您的两个输入数组进行了排序.
BTW: Don''t forget to make sure that your two input arrays are sorted before starting the merge.