Didart

NxN Matrix

Oct 10th, 2021
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class NxN_Matrix {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int number = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int i = 0; i < number; i++) {
  10.             row(number);
  11.         }
  12.     }
  13.  
  14.     private static void row(int n) {
  15.         for (int i = 0; i < n; i++) {
  16.             System.out.print(n + " ");
  17.         }
  18.         System.out.println();
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment