SUni2020

Квадрат от звездички

Mar 23rd, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. package FirstStepsInCoding;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class Pr06SquareOfStar {
  8. public static void main(String[] args) {
  9. String star = "*";
  10. Scanner s2 = new Scanner(System.in);
  11. int n = s2.nextInt();
  12. for (int a = 1; a <= n; a++) {
  13. if (a == 1 || a == n) {
  14. for (int i = 1; i <= n; i++) {
  15. System.out.print(star);
  16. }
  17. } else for (int b = 1; b <= n; b++) {
  18. if (b == 1 || b == n) {
  19. System.out.print(star);
  20. } else System.out.print(" ");
  21. }
  22. System.out.print("\n");
  23. }
  24. }
  25. }
Add Comment
Please, Sign In to add comment