嗨所以问题是:如果array1小于array2用数字1替换缺失值,这样array1缺失值可以乘以array2,就好像它们是数字1一样?这是我对如何去做的想法......帮助正确的语法?最好的方法是什么?
public addMissingNumber(int[] array1, int[] array2){
for (int 1 = array1.length; i > 0; i--)
for(int j = array2.length; j > 0; j--){
if(array1[i] < array2[j]) {
array1[i].[j] = 1;
/*what I want to say here is that the empty position of the array1[i] that is equivalent to the position of array2[j] that contains a number should become the number 1. How can this be done?*
}
}
}
这是原始考试问题,第二部分是我遇到的麻烦:编写一个名为 add 的方法,该方法接受两个 double 类型的数组 v、w 作为其参数。该方法应返回一个新的 double 数组,该数组是通过添加输入数组的相应元素而形成的。也就是说,输出数组的元素 i 应该等于 v[i]+w[i]。
如果 v 和 w 的长度不同,则输出数组的长度应为 (v.length, w.length) 的最大值。在计算输出时,应假定较短数组的缺失元素为 1。