Advertisement
desislava_topuzakova

Crown

Feb 11th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Crown {
  4.     public static void main(String[] agrs) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         int width = (2 * n) - 1;
  10.         int heigth = (n / 2) + 4;
  11.         int counterStarsMiddle = 0;
  12.         String down = repeatStr("*", width);
  13.  
  14.         String up = "@" + repeatStr(" ", n - 2)
  15.                 + "@" + repeatStr(" ", n - 2) + "@";
  16.         String beforeMiddle = "**" + repeatStr(" ", n - 3)
  17.                 + "*" + repeatStr(" ", n - 3) + "**";
  18.  
  19.         System.out.println(up);
  20.         System.out.println(beforeMiddle);
  21.  
  22.         for (int i = 1; i <= n / 2 - 2; i++) {
  23.             String middle = "*" + repeatStr(".", i) + "*"
  24.                     + repeatStr(" ", n - 3 - i - i)
  25.                     + "*" + repeatStr(".", i + counterStarsMiddle) + "*"
  26.                     + repeatStr(" ", n - 3 - i - i)
  27.                     + "*" + repeatStr(".", i) + "*";
  28.             counterStarsMiddle += 1;
  29.             System.out.println(middle);
  30.         }
  31.         String firstLineAfterCrown = "*" + repeatStr(".", n / 2 - 1) + "*"
  32.                 + repeatStr(".", n - 3) + "*"
  33.                 + repeatStr(".", n / 2 - 1) + "*";
  34.  
  35.         System.out.println(firstLineAfterCrown);
  36.  
  37.         String secondLineAfterCrown = "*" + repeatStr(".", n / 2)
  38.                 + repeatStr("*", n / 2 - 2) + "."
  39.                 + repeatStr("*", n / 2 - 2)
  40.                 + repeatStr(".", n / 2) + "*";
  41.  
  42.         System.out.println(secondLineAfterCrown);
  43.         System.out.println(down);
  44.         System.out.println(down);
  45.     }
  46.  
  47.     static String repeatStr(String str, int count) {
  48.         String text = "";
  49.         {
  50.             for (int j = 0; j < count; j++) {
  51.                 text = text + str;
  52.             }
  53.  
  54.         }
  55.         return text;
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement