Advertisement
desislava_topuzakova

07. NxN Matrix

Oct 8th, 2022
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. package methods;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class NxNMatrix_07 {
  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. for (int row = 1; row <= n; row++) {
  14. for (int col = 1; col <= n; col++) {
  15. System.out.print(n + " ");
  16. }
  17. System.out.println();
  18. }
  19. }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement