解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[][] st=new int [n][n];
int sum=0;
for(int i=0;i<st.length;i++){
for(int x=0;x<st[i].length;x++){
st[i][x]=sc.nextInt();
if(i==x|i+x==n-1)
sum+=st[i][x];}
}
System.out.print(sum);
}
}
0.0分
0 人评分
A+B for Input-Output Practice (C语言代码)浏览:468 |
简单的a+b (C语言代码)浏览:488 |
1128题解(返回值为数组的情况)浏览:474 |
图形输出 (C语言代码)浏览:945 |
班级人数 (C语言代码)浏览:927 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:565 |
10月月赛题解浏览:536 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:423 |
C二级辅导-公约公倍 (C语言代码)浏览:663 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:641 |