AcWing 813. 打印矩阵 - Java
原题链接
简单
作者:
KYCygni
,
2021-03-20 23:26:16
,
所有人可见
,
阅读 244
Java 代码
import java.util.Scanner;
public class Main
{
public static void print2D (int[][] nums, int row, int col)
{
for (int i = 0; i < row; i ++)
{
for (int j = 0; j < col; j ++)
System.out.print(nums [i][j] + " ");
System.out.print("\n");
}
}
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int row = cin.nextInt();
int col = cin.nextInt();
int[][] nums = new int[row][col];
for (int i = 0; i < row; i ++)
{
for (int j = 0; j < col; j ++)
{
nums[i][j] = cin.nextInt();
}
}
print2D (nums, row, col);
}
}