Advertisement
prozac11

pp

Nov 16th, 2019
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1.  
  2. import java.util.Arrays;
  3. import java.util.Locale;
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Hiekkalaatikko {
  8.  
  9.     public static Scanner reader = new Scanner(System.in).useLocale(Locale.FRANCE);
  10.  
  11.     public static void main(String[] args) {
  12.  
  13.         int rows, columns;
  14.  
  15.         System.out.print("Type in the number of rows: ");
  16.         rows = reader.nextInt();
  17.         System.out.print("Type in the number of columns: ");
  18.         columns = reader.nextInt();
  19.  
  20.         int matrix[][];
  21.  
  22.         matrix = askInfo(rows, columns);
  23.         printMatrix(matrix);
  24.         //countSum(matrix);
  25.     }
  26.  
  27.  
  28.     private static int[][] askInfo(int rows, int columns) {
  29.         int[][] list = new int[rows][columns];
  30.         for (int a = 0; a < list.length; a++) {
  31.             for (int i = 0; i < list[a].length; i++) {
  32.                 System.out.print("Type in the element " + (a + 1) + " of the row " + (i + 1) + ": ");
  33.                 list[a][i] = reader.nextInt();
  34.  
  35.             }
  36.         }
  37.  
  38.         return list;
  39.  
  40.     }
  41.  
  42.     private static void printMatrix(int[][] matrix) {
  43.  
  44.         for (int a = 0; a < matrix.length; a++) {
  45.             for (int i = 0; i < matrix[a].length; i++) {
  46.                 System.out.print("Matrix: " + matrix[i] + " " + matrix[a]);
  47.             }
  48.  
  49.  
  50.         }
  51.  
  52.     }
  53.     private static void coun
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement