Advertisement
Spocoman

02. Rectangle of N x N Stars(with or not repeat())

Aug 31st, 2024
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class RectangleOfNStars {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine());
  7.         for (int i = 0; i < n; i++) {
  8.             for (int j = 0; j < n; j++) {
  9.                 System.out.print('*');
  10.             }
  11.             System.out.println();
  12.         }
  13.     }
  14. }
  15.  
  16. ИЛИ:
  17.  
  18. import java.util.Scanner;
  19.  
  20. public class 02. RectangleOfNStars {
  21.     public static void main(String[] args) {
  22.         Scanner scanner = new Scanner(System.in);
  23.         int n = Integer.parseInt(scanner.nextLine());
  24.         for (int i = 0; i < n; i++) {
  25.             System.out.println(("*").repeat(n));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement