Advertisement
Lyubohd

Untitled

Jun 25th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Crown {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scan.nextLine());
  8.  
  9.         //FirstPart
  10.         int space = n - 2;
  11.         System.out.printf("@%s@%s@%n",
  12.                 repeatStr(" ", space),
  13.                 repeatStr(" ", space));
  14.         //SecondPart
  15.         space--;
  16.         System.out.printf("**%s*%s**%n",
  17.                 repeatStr(" ", space),
  18.                 repeatStr(" ", space));
  19.  
  20.         //ThirdPart
  21.         int end = (n / 2 - 1) - 1;
  22.         space -= 2;
  23.         int midPonits = 1;
  24.         int leftPoints = 1;
  25.  
  26.         for (int row = 1; row <= end; row++) {
  27.             System.out.printf("*%s*%s*%s*%s*%s*%n",
  28.                     repeatStr(".", leftPoints),
  29.                     repeatStr(" ", space),
  30.                     repeatStr(".", midPonits),
  31.                     repeatStr(" ", space),
  32.                     repeatStr(".", leftPoints));
  33.             midPonits += 2;
  34.             leftPoints++;
  35.             space -= 2;
  36.         }
  37.         //FourthPart
  38.         System.out.printf("*%s*%s*%s*%n",
  39.                 repeatStr(".", leftPoints),
  40.                 repeatStr(".", midPonits),
  41.                 repeatStr(".", leftPoints));
  42.         midPonits = (midPonits - 1) / 2;
  43.         leftPoints++;
  44.  
  45.         //FifthPart
  46.         System.out.printf("*%s%s.%s%s*%n",
  47.                 repeatStr(".", leftPoints),
  48.                 repeatStr("*", midPonits),
  49.                 repeatStr("*", midPonits),
  50.                 repeatStr(".", leftPoints));
  51.         int weigt = (2 * n) - 1;
  52.  
  53.         //LastPart
  54.         for (int i = 0; i < 2; i++) {
  55.             System.out.printf("%s%n", repeatStr("*", weigt));
  56.         }
  57.     }
  58.  
  59.     static String repeatStr(String strToRepeat, int count) {
  60.         String text = "";
  61.  
  62.         for (int i = 0; i < count; i++) {
  63.             text = text + strToRepeat;
  64.         }
  65.  
  66.         return text;
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement