Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ChristmassSock {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- System.out.printf("|%s|%n", partOfRow("-", 2 * n));
- System.out.printf("|%s|%n", partOfRow("*", 2 * n));
- System.out.printf("|%s|%n", partOfRow("-", 2 * n));
- for (int i = 0; i < n - 1; i++) {
- System.out.printf("|%s%s%s|%n", partOfRow("-", n - 1 - i ),
- partOfRow("~", i * 2 + 2), partOfRow("-", n - 1 - i ));
- }
- for (int i = n - 2; i > 0; i--) {
- System.out.printf("|%s%s%s|%n", partOfRow("-", n - i ),
- partOfRow("~", i * 2), partOfRow("-", n - i ));
- }
- for (int i = 0; i < n + 3 - 1; i++) {
- if (i == n / 2) {
- System.out.printf("%s\\%sMERRY%s\\%n", partOfRow("-", i), partOfRow(".", n - 2),
- partOfRow(".", n - 2));
- } else if (i == n / 2 + 2) {
- System.out.printf("%s\\%sX-MAS%s\\%n", partOfRow("-", i), partOfRow(".", n - 2),
- partOfRow(".", n - 2));
- } else {
- System.out.printf("%s\\%s\\%n", partOfRow("-", i), partOfRow(".", 2 * n + 1));
- }
- }
- System.out.printf("%s\\%s)%n", partOfRow("-", n + 2), partOfRow("_", 2 * n + 1));
- }
- private static String partOfRow(String symbol, int count) {
- StringBuilder stringBuilder = new StringBuilder();
- for (int i = 0; i < count; i++) {
- stringBuilder.append(symbol);
- }
- return stringBuilder.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement