Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Sunglasses {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- String firstAndLastLine = "*" + repeatStr(".", n) + "*" + repeatStr(".", n) + "*";
- System.out.println(firstAndLastLine);
- for (int i = 0; i <= n / 2; i++) {
- String line = repeatStr(".", (2 * n + 3) - (2 * n + 2) + i)
- + "*"
- + repeatStr(".", (2 * n + 3) - (5 + (n - 1)) - i)
- + "*"
- + repeatStr(".", (2 * n + 3) - (5 + (n - 1)) - i)
- + "*"
- + repeatStr(".", (2 * n + 3) - (2 * n + 2) + i);
- System.out.println(line);
- }
- String middle = repeatStr(".", n - 1) + "*****" + repeatStr(".", n - 1);
- System.out.println(middle);
- String middleLine = repeatStr("*", 2 * n + 3);
- System.out.println(middleLine);
- System.out.println(middle);
- for (int i = 0; i <= n / 2 + 1; i++) {
- String line = repeatStr(".", ((2 * n + 3) - 7) / 2 - i)
- + "*"
- + repeatStr(".", ((2 * n + 3) - (2 * n - 4) - 3) / 2 + i)
- + "*"
- + repeatStr(".", ((2 * n + 3) - (2 * n - 4) - 3) / 2 + i)
- + "*"
- + repeatStr(".", ((2 * n + 3) - 7) / 2 - i);
- System.out.println(line);
- }
- System.out.println(firstAndLastLine);
- }
- public static String repeatStr(String str, int count) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < count; i++) {
- sb.append(str);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement