Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Crown {
- public static void main(String[] agrs) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- int width = (2 * n) - 1;
- int heigth = (n / 2) + 4;
- int counterStarsMiddle = 0;
- String down = repeatStr("*", width);
- String up = "@" + repeatStr(" ", n - 2)
- + "@" + repeatStr(" ", n - 2) + "@";
- String beforeMiddle = "**" + repeatStr(" ", n - 3)
- + "*" + repeatStr(" ", n - 3) + "**";
- System.out.println(up);
- System.out.println(beforeMiddle);
- for (int i = 1; i <= n / 2 - 2; i++) {
- String middle = "*" + repeatStr(".", i) + "*"
- + repeatStr(" ", n - 3 - i - i)
- + "*" + repeatStr(".", i + counterStarsMiddle) + "*"
- + repeatStr(" ", n - 3 - i - i)
- + "*" + repeatStr(".", i) + "*";
- counterStarsMiddle += 1;
- System.out.println(middle);
- }
- String firstLineAfterCrown = "*" + repeatStr(".", n / 2 - 1) + "*"
- + repeatStr(".", n - 3) + "*"
- + repeatStr(".", n / 2 - 1) + "*";
- System.out.println(firstLineAfterCrown);
- String secondLineAfterCrown = "*" + repeatStr(".", n / 2)
- + repeatStr("*", n / 2 - 2) + "."
- + repeatStr("*", n / 2 - 2)
- + repeatStr(".", n / 2) + "*";
- System.out.println(secondLineAfterCrown);
- System.out.println(down);
- System.out.println(down);
- }
- static String repeatStr(String str, int count) {
- String text = "";
- {
- for (int j = 0; j < count; j++) {
- text = text + str;
- }
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement