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