java从键盘输入6个小数,给定义的两行三列二维数组赋值,并输出他们的和?

2024-12-02 03:37:29
推荐回答(1个)
回答1:

import java.util.Scanner;

public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int[][] array = new int[3][2];
int sum = 0;
for(int x = 0;x < 3;x++){
for(int y = 0;y < 2;y++){
array[x][y] = sc.nextInt();
sum += array[x][y];
}
}
System.out.println(sum);
}
}