Lover


私信TA

用户名:17837185450

访问量:6985

签 名:

楼上的快敲代码,我追上你了

等  级
排  名 2346
经  验 2272
参赛次数 0
文章发表 15
年  龄 0
在职情况 学生
学  校 河南农业大学
专  业

  自我简介:

参考代码:

import java.util.Scanner;


public class Main1138 {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

int x = sc.nextInt();

int a[][] = new int[x][x];

int sum = 0;

for (int i = 0; i < x; i++) {

for (int j = 0; j < x; j++) {

a[i][j] = sc.nextInt();

if (i == j || i + j == x - 1) {

sum += a[i][j];

}

}

}

System.out.println(sum);

}

}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

谢谢
2020-01-09 23:07:20
  • «
  • 1
  • »