java二维数组的个数_Java | 通过遍历第一个数组的正向和第二个数组的后向,打印两个二维数组的乘法...

java二维数组的个数

Here, We have to find the multiplication of the two matrix by moving forward direction in row major (row by row) order in one matrix and by backward direction in row major order in second one i.e. multiplying first element of one matrix with the last element of second one, second element of first one with the second last element of second one and so on…

在这里,我们必须通过以下方式找到两个矩阵的乘法:在一个矩阵中按行主要(行)顺序向前移动,在第二个矩阵中按行主要顺序向后移动,即将一个矩阵的第一个元素与最后一个元素相乘第二个元素的第一个元素,第二个元素的倒数第二个元素的第二个元素,依此类推…

Example:

例:

First matrix (X)
   8	    9	     5
   5	    6	     3
   4	    9	     7

Second matrix (Y)
     6	     8	   10
    12	     4	    5
     3	    17	   20

We have to multiply like that,

我们必须那样繁衍,

First element of first matrix (X) with the last one of second matrix (Y) → 8*20 and save it to the first index of new matrix. Then , 9*17 and save it to the 2nd index of new one and so on...

第一个矩阵( X )的第一个元素与第二个矩阵( Y )的最后一个元素→8 * 20,并将其保存到新矩阵的第一个索引中。 然后,9 * 17并将其保存到新索引的第二个索引,依此类推...

The new Matrix Z is

新的Matrix Z是

    160		153		15
    24		25		36
    40		72		42

Program:

程序:

public class Multiplication 
{
	public static void main(String[] args) 
	{
		//first matrix
		int x[][]={{8,9,5},{5,6,3},{4,9,7}};  
		//second matrix
		int y[][]={{6,8,10},{12,4,5},{3,17,20}}; 
		//matrix which stores multiplication of the two
		int z[][]=new int[3][3];  
		
		for(int i=0,j=2;i<3;i++,j--)
			for(int k=0,l=2;k<3;k++,l--)
				z[i][k]=x[i][k]*y[j][l];
			
		for(int i=0;i<3;i++)
		{
			for(int j=0;j<3;j++)
				System.out.print(z[i][j]+" ");
			System.out.println();
		}
	}
}

Output

输出量

Multiplication of two 2-D Arrays

翻译自: https://www.includehelp.com/java-programs/print-multiplication-of-two-2-d-arrays-by-traversing-forward-direction.aspx

java二维数组的个数

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值