Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Locale;
- import java.util.Scanner;
- public class Hiekkalaatikko {
- public static Scanner reader = new Scanner(System.in).useLocale(Locale.FRANCE);
- public static void main(String[] args) {
- int rows, columns;
- System.out.print("Type in the number of rows: ");
- rows = reader.nextInt();
- System.out.print("Type in the number of columns: ");
- columns = reader.nextInt();
- int matrix[][];
- matrix = askInfo(rows, columns);
- printMatrix(matrix);
- //countSum(matrix);
- }
- private static int[][] askInfo(int rows, int columns) {
- int[][] list = new int[rows][columns];
- for (int a = 0; a < list.length; a++) {
- for (int i = 0; i < list[a].length; i++) {
- System.out.print("Type in the element " + (a + 1) + " of the row " + (i + 1) + ": ");
- list[a][i] = reader.nextInt();
- }
- }
- return list;
- }
- private static void printMatrix(int[][] matrix) {
- for (int a = 0; a < matrix.length; a++) {
- for (int i = 0; i < matrix[a].length; i++) {
- System.out.print("Matrix: " + matrix[i] + " " + matrix[a]);
- }
- }
- }
- private static void coun
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement