三个疑问
1.数组如何一一对应元素相乘
2.数组里的数如何想加
3.数组如何遍历
除此之外,此题要用到count方法
使用Nd4j 轻松操作多维数组
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>1.0.0-beta7</version>
</dependency>
public static void main(String[] args) {
INDArray nd1 = Nd4j.create(new double[] {1,3,2,4});
System.out.println(nd1);
INDArray nd2 = Nd4j.create(new double[] {4,1,7,9});
System.out.println(nd2);
INDArray muli = nd1.muli(nd2);
System.out.println(muli.toString());
int sum = muli.sumNumber().intValue();
System.out.println(sum);
}