当前位置:网站首页>Reshape a two-dimensional array with 3 rows and 3 columns to find the sum of the diagonals
Reshape a two-dimensional array with 3 rows and 3 columns to find the sum of the diagonals
2022-06-26 10:21:00 【m0_ sixty-one million nine hundred and sixty-one thousand eight】
public static void main(String[] args) {
int sum = 0;
int z [][]=new int [3][3];
z[0] = new int [] {1, 2, 3};
z[1] = new int [] {4, 5, 6};
z[2] = new int [] {7, 8 ,9};
for (int i=0 ;i<3;i++) {
for (int j=0; j<3;j++) {
if (i ==j) {
sum = sum + z[i][j];
}
}
}
System.out.println( sum);
}
}The result is 15

边栏推荐
- Threading model in webrtc native
- MySQL第十一作业-视图的应用
- Nested recyclerview in nestedscrollview automatically slides to the bottom after switching
- 首批12家企业入驻!广州首个集中展销老字号产品专柜开张
- Threadmode interpretation of eventbus
- Redis master-slave replication in win10 system
- Selection of webrtc video codec type VP8 H264 or other? (openh264 encoding, ffmpeg decoding)
- Global and Chinese market of recycled paper 2022-2028: Research Report on technology, participants, trends, market size and share
- Constraintlayout control uses full Raiders
- Servlet learning notes II
猜你喜欢

Jar version conflict resolution

如何更改微信小程序二维码物料颜色

創建對象的時候堆內存的分配

Renesas electronics launched a complete intelligent sensor solution for Internet of things applications

Some problems to be considered when designing technical implementation scheme

Redis master-slave replication in win10 system

Call API interface to generate QR code of wechat applet with different colors

exec系列函数(execl、execlp、execle、execv、execvp)使用

【LeetCode】59. Spiral matrix II

A list of common methods for customizing paint and canvas of view
随机推荐
[binary search] 4 Find the median of two positive arrays
DBSCAN
echo $?
Configuration internationale
Basic string operations in C
Record the handling of oom problems caused by too many threads at one time
904. fruit baskets
首批12家企业入驻!广州首个集中展销老字号产品专柜开张
Win10安装tensorflow-quantum过程详解
美国总统签署社区安全法案以应对枪支问题
druid数据源实现后台监控
从tf 1.x到tf 2.6(遇到的就过来更新更新)
TensorFlow遇到的各种错误
Index summary of blog articles -- Industrial Internet
Use of exec series functions (EXECL, execlp, execle, execv, execvp)
What are the symbolic and direct references of the JVM
Problems encountered by jupyter notebook
P1296 whispers of cows (quick row + binary search)
35 qlineedit control synthesis example
From TF 1 X to TF 2.6 (update if you encounter it)