Advertisement
Guest User

Untitled

a guest
Jul 4th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.49 KB | None | 0 0
  1. package mask;
  2.  
  3.  
  4. import java.io.BufferedReader;
  5. import java.io.IOException;
  6. import java.io.InputStreamReader;
  7.  
  8. public class Mask {
  9.  
  10.     public static String strRepeat(String str, int count) {
  11.         String result = "";
  12.         for (int i = 0; i < count; i++) {
  13.             result +=  str;
  14.         }
  15.         return result;
  16.     }
  17.  
  18.     public static void main(String[] args) throws IOException {
  19.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  20.  
  21.         int n = Integer.parseInt(reader.readLine());
  22.         int length = 4 * n - 1;
  23.         int width = (2 * n) + 2;
  24.         int spaces = n - 3;
  25.  
  26.         System.out.printf("%s/|  |\\\n", strRepeat(" ", n-2));
  27.  
  28.        
  29.         for (int i = 1; i < n-1; i++) {
  30.             System.out.printf("%s/%s|  |%s\\\n",
  31.                     strRepeat(" ", spaces),
  32.                     strRepeat(" ", i),
  33.                     strRepeat(" ", i));
  34.             spaces--;
  35.         }
  36.        
  37.         System.out.println(strRepeat("-", width));
  38.  
  39.        
  40.        
  41.        
  42.        
  43.        
  44.         /*
  45.         System.out.printf("|%s_%s_%s|\n", strRepeat(" ", n/3),
  46.                 strRepeat(" ", width - (2 * (n/3) + 4)),
  47.                 strRepeat(" ", n/3));
  48.  
  49.         System.out.printf("|%s@%s@%s|\n", strRepeat(" ", n/3),
  50.                 strRepeat(" ", width - (2 * (n/3) + 4)),
  51.                 strRepeat(" ", n/3));
  52.         */
  53.        
  54.         String t = strRepeat(" ",(n - 3) / 2);
  55.         System.out.println("|" + t +  "_" + strRepeat(" ",2*n+2 - 2*(t.length() +2)) + "_" + t  + "|");
  56.         System.out.println("|" + t  +  "@" + strRepeat(" ",2*n+2 - 2*(t.length() +2)) + "@" + t  + "|");
  57.  
  58.        
  59.        
  60.        
  61.        
  62.        
  63.        
  64.        
  65.        
  66.         for (int i = 0; i < n / 2; i++) {
  67.             System.out.printf("|%s|\n", strRepeat(" ", width - 2));
  68.         }
  69.  
  70.         System.out.printf("|%sOO%s|\n", strRepeat(" ", n-1), strRepeat(" ", n-1));
  71.         System.out.printf("|%s/  \\%s|\n", strRepeat(" ", n-2), strRepeat(" ", n-2));
  72.         System.out.printf("|%s||||%s|\n", strRepeat(" ", n-2), strRepeat(" ", n-2));
  73.         System.out.printf("\\%s/\n", strRepeat("`", width - 2));
  74.  
  75.         for (int i = 2; i <= n; i++) {
  76.             System.out.printf("%s%s%s\n", strRepeat("\\", i),
  77.                     strRepeat("`", width - (2 * i)),
  78.                     strRepeat("/", i));
  79.         }
  80.  
  81.         System.out.printf("%s%s", strRepeat("\\", width/2), strRepeat("/", width/2));
  82.  
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement