This commit is contained in:
2024-10-08 05:45:58 -04:00
parent 9aab140ad1
commit fa5ac5e089
5 changed files with 201 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import java.util.ArrayList;
import java.util.Scanner;
/**
* MatrixInput
*/
public class MatrixInput {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the 2D Array here: ");
System.out.println("Numbers of rows: ");
int rows = sc.nextInt();
System.out.println("Numbers of columns: ");
int columns = sc.nextInt();
int[][] arr = new int[rows][columns];
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
arr[i][j] = sc.nextInt();
}
}
System.out.println("");
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
System.out.print(arr[i][j]);
}
System.out.println();
}
}
}