📜  添加两个数组 - 无论代码示例

📅  最后修改于: 2022-03-11 14:58:32.108000             🧑  作者: Mango

代码示例1
int[] a = {10, 20 30, 40}; int[] b = {25, 50, 75, 100, 125}; int[] sum = new int[b.length];  for (int i = 0; i <= b.length; i++){     sum[i] = 0;             /*initialize each of the sum values as zeroes, because that's         what we usually start with*/              if (i > b.length){          /*if one array is longer than the other, just add zero the          remaining elements in the largest array*/         sum[i] = b[i] + 0;     else{         sum[i] = a[i] + b[i];     } }