构造一个m行n列的二维数组(mln的取值均小于等于4, mln均由键盘输入),并由键盘输入数组元素的值,并且按照矩阵的形式输出
Scanner sc = new Scanner(System.in); System.out.println("请输入行"); int m = sc.nextInt(); System.out.println("请输入列"); int n = sc.nextInt(); System.out.println(m+"行"+n+"列"); brr= new int[m][n]; for (int i = 0; i < m; i++){ for (int j = 0; j < n; j++){ System.out.println("请输入第行"+(i+1)+"第"+(j+1)+"列"); brr[i][j] = sc.nextInt(); } } for (int i = 0; i < brr.length; i++){ for (int j = 0; j <brr[i].length; j++){ System.out.print("brr["+i+"]["+j+"]="+brr[i][j]+" "); } System.out.println(); }