Get the App
SLTechnology News&Howtos  ›  Development  › 

How to find the Sum of diagonal elements of a 3-3 Matrix by Java

Shulou Source: shulou.com Published: 2022-06-01 04:16:12 10月02日 Update

This article mainly shows you "Java how to find the sum of diagonal elements of a 3x3 matrix", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Java how to find a sum of diagonal elements of a 30003 matrix" this article.

Find the sum of diagonal elements of a 3-3 matrix

This is a matrix programming implementation problem. Matrices in Java are generally implemented through two-dimensional arrays.

The specific code is as follows:

Import java.util.Random;/** * find the sum of the diagonal elements of a 3'3 matrix * * @ author ChenZX * * / public class Test04 {public static void main (String [] args) {int sum = 0; / / and int [] [] arr = new int [3] [3]; Random r = new Random (); for (int iPisti)

Tags: Matrix element diagonal diagonal sum content article study help one code array easy to understand more organization knowledge ribbon industry information information channel Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Redmi Shulou Information Linux Docker