Advertisement
Guest User

Untitled

a guest
Jun 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.87 KB | None | 0 0
  1. package Demos;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class DemoClass {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int n = Integer.parseInt(scan.nextLine());
  10.         int width = 5 * n;
  11.  
  12.         for (int i = 0; i < n / 2; i++) {
  13.             System.out.println(String.format("%s%s%s",
  14.                     repeat(".", n + i),
  15.                     repeat("#", n * 3 - i * 2),
  16.                     repeat(".", n + i)
  17.             ));
  18.         }
  19.  
  20.         for (int i = 0; i < n / 2 + 1; i++) {
  21.             System.out.println(String.format("%s#%s#%s",
  22.                     repeat(".", n + i + n / 2),
  23.                     repeat(".", n * 2 - 2 - i * 2),
  24.                     repeat(".", n + i + n / 2)
  25.             ));
  26.         }
  27.  
  28.         System.out.println(String.format("%s%s%s",
  29.                 repeat(".", n * 2),
  30.                 repeat("#", n),
  31.                 repeat(".", n * 2)
  32.         ));
  33.  
  34.         for (int i = 0; i < n / 2; i++) {
  35.             System.out.println(String.format("%s%s%s",
  36.                     repeat(".", n * 2 - 2),
  37.                     repeat("#", n + 4),
  38.                     repeat(".", n * 2 - 2)
  39.             ));
  40.         }
  41.  
  42.         System.out.println(String.format("%sD^A^N^C^E^%s",
  43.                 repeat(".", (width - 10) / 2),
  44.                 repeat(".", (width - 10) / 2)
  45.         ));
  46.  
  47.         for (int i = 0; i < n / 2 + 1; i++) {
  48.             System.out.println(String.format("%s%s%s",
  49.                     repeat(".", n * 2 - 2),
  50.                     repeat("#", n + 4),
  51.                     repeat(".", n * 2 - 2)
  52.             ));
  53.         }
  54.     }
  55.  
  56.     static String repeat(String strToRepeat, int count) {
  57.         StringBuilder text = new StringBuilder();
  58.         for (int i = 0; i < count; i++) {
  59.             text.append(strToRepeat);
  60.         }
  61.         return text.toString();
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement