当前位置:网站首页>3行3列整形二维数组,求对角之和
3行3列整形二维数组,求对角之和
2022-06-26 09:37:00 【m0_61961898】
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);
}
}结果为15

边栏推荐
- 定制拦截器
- [sans titre]
- Deep learning (tentsorflow2. version) three good student performance problems (1)
- 如何更改微信小程序二维码物料颜色
- Various errors encountered by tensorflow
- cmake / set 命令
- The third-party extension package of thinkphp6.0 supports uploading to Alibaba cloud and qiniu cloud
- Openxcap usage
- Druid data source for background monitoring
- c语言语法基础之——函数 小程序 求阶乘
猜你喜欢

【Leetcode】76. 最小覆盖子串

What is the web SSH service port of wgcloud

Druid data source for background monitoring

Internationalization configuration

The IE mode tab of Microsoft edge browser is stuck, which has been fixed by rolling back the update

Constraintlayout control uses full Raiders

Force buckle ----- remove the maximum and minimum values from the array

Cloud native essay using Hana expression database service on Google kubernetes cluster

904. 水果成篮

The basis of C language grammar -- pointer (multidimensional array, function, summary) learning
随机推荐
The basis of C language grammar -- pointer (multidimensional array, function, summary) learning
In the fragment, the input method is hidden after clicking the confirm cancel button in the alertdialog (this is valid after looking for it on the Internet for a long time)
Threadmode interpretation of eventbus
cmake / set 命令
Leetcode intermediate node of linked list
What is the web SSH service port of wgcloud
Allocation of heap memory when creating objects
Automated testing -- Introduction and example of pytest framework
Some problems to be considered when designing technical implementation scheme
Differences between JVM, Dalvik and art
c语言语法基础之——指针(字符、一维数组) 学习
Develop current learning objectives and methods
Cento7.7 elk installation simple record
Custom interceptor
Extracting public fragments from thymeleaf
Tensorflow dynamically allocates video memory
How do technicians send notifications?
DAY 3 数组,前置后置,字符空间,关键词和地址指针
c语言语法基础之——函数嵌套、递归 小程序斐波那契之和、阶乘
WGCLOUD的web ssh服务端口是多少