desislava_topuzakova

4. NxN матрица

Feb 13th, 2022
1,192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. package Methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Matrix_04 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int n = Integer.parseInt(scanner.nextLine());
  9.         printMatrix(n);
  10.     }
  11.  
  12.     public static void printMatrix (int n) {
  13.         //n -> брой на редовете, брой на колоните
  14.         for (int row = 1; row <= n; row++) {
  15.             for (int col = 1; col <= n; col++) {
  16.                 System.out.print(n + " ");
  17.             }
  18.             System.out.println();
  19.         }
  20.     }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment