Advertisement
Spocoman

Draw Fort

Sep 4th, 2024
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine()),
  7.                 x = n > 4 ? n * 2 - (n / 2 + 2) * 2 : 0;
  8.  
  9.         System.out.printf("/%s\\%s/%s\\\n", "^".repeat(n / 2), "_".repeat(x), "^".repeat(n / 2));
  10.  
  11.         for (int i = 0; i < n - 3; i++) {
  12.             System.out.printf("|%s|\n", " ".repeat(n * 2 - 2));
  13.         }
  14.  
  15.         System.out.printf("|%s%s%s|\n", " ".repeat((n * 2 - (x + 2)) / 2), "_".repeat(x), " ".repeat((n * 2 - (x + 2)) / 2));
  16.  
  17.         System.out.printf("\\%s/%s\\%s/\n", "_".repeat(n / 2), " ".repeat(x), "_".repeat(n / 2));
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement