首页 > 代码库 > 已知2个一维数组:a[]={3,4,5,6,7},b[]={1,2,3,4,5,6,7};把数组a与数组b 对应的元素乘积再赋值给数组b,如:b[2]=a[2]*b[2];最后输出数组b的元素。

已知2个一维数组:a[]={3,4,5,6,7},b[]={1,2,3,4,5,6,7};把数组a与数组b 对应的元素乘积再赋值给数组b,如:b[2]=a[2]*b[2];最后输出数组b的元素。

package com.homework.zw;public class work1 {    public static void main(String[] args)     {        int[] a ={3,4,5,6};        int[] b ={1,2,3,4,5,6,7};         System.out.print("b[]={");        for(int i =0;i<=3;i++)        {            b[i]=a[i]*b[i];            System.out.print(b[i]+",");                    }        System.out.println("}");           }}

技术分享

 

已知2个一维数组:a[]={3,4,5,6,7},b[]={1,2,3,4,5,6,7};把数组a与数组b 对应的元素乘积再赋值给数组b,如:b[2]=a[2]*b[2];最后输出数组b的元素。