Advertisement
YavorGrancharov

DrawFort

Feb 12th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class DrawFort {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         int n = Integer.parseInt(console.nextLine());
  7.         int k = 0;
  8.         if (n % 2 != 0) {
  9.             k = 1;
  10.         }
  11.         System.out.println("/" + repeatStr("^", n / 2) + "\\" + repeatStr("_", 2*n-n-4+k) + "/" + repeatStr("^", n / 2) + "\\");
  12.  
  13.         for (int i = 0; i < n - 2; i++) {
  14.             if (i != n - 3) {
  15.                 System.out.println("|" + repeatStr(" ", 2 * n - 2) + "|");
  16.             } else {
  17.                 System.out.println("|" + repeatStr(" ", n/2 + 1) + repeatStr("_", 2*n-n-4+k) + repeatStr(" ", n/2 + 1) + "|");
  18.             }
  19.         }
  20.         System.out.println("\\" + repeatStr("_", n/2) + "/" + repeatStr(" ", 2*n-n-4+k) + "\\" + repeatStr("_", n/2) + "/");
  21.     }
  22.     static String repeatStr(String str, int count) {
  23.         StringBuilder repeated = new StringBuilder();
  24.         for (int i = 0; i < count; i++) {
  25.             repeated.append(str);
  26.         }
  27.         return repeated.toString();
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement