Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Demos;
- import java.util.Scanner;
- public class DemoClass {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int n = Integer.parseInt(scan.nextLine());
- int width = 5 * n;
- for (int i = 0; i < n / 2; i++) {
- System.out.println(String.format("%s%s%s",
- repeat(".", n + i),
- repeat("#", n * 3 - i * 2),
- repeat(".", n + i)
- ));
- }
- for (int i = 0; i < n / 2 + 1; i++) {
- System.out.println(String.format("%s#%s#%s",
- repeat(".", n + i + n / 2),
- repeat(".", n * 2 - 2 - i * 2),
- repeat(".", n + i + n / 2)
- ));
- }
- System.out.println(String.format("%s%s%s",
- repeat(".", n * 2),
- repeat("#", n),
- repeat(".", n * 2)
- ));
- for (int i = 0; i < n / 2; i++) {
- System.out.println(String.format("%s%s%s",
- repeat(".", n * 2 - 2),
- repeat("#", n + 4),
- repeat(".", n * 2 - 2)
- ));
- }
- System.out.println(String.format("%sD^A^N^C^E^%s",
- repeat(".", (width - 10) / 2),
- repeat(".", (width - 10) / 2)
- ));
- for (int i = 0; i < n / 2 + 1; i++) {
- System.out.println(String.format("%s%s%s",
- repeat(".", n * 2 - 2),
- repeat("#", n + 4),
- repeat(".", n * 2 - 2)
- ));
- }
- }
- static String repeat(String strToRepeat, int count) {
- StringBuilder text = new StringBuilder();
- for (int i = 0; i < count; i++) {
- text.append(strToRepeat);
- }
- return text.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement