Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_06_March_2016 - created by borkins on 2017-05-14.
- */
- import java.util.Scanner;
- public class _05_DrawFort
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- String columnTop = "/" + new String(new char[n / 2]).replace("\0", "^") + "\\";
- String columnBottom = "\\" + new String(new char[n / 2]).replace("\0", "_") + "/";
- String centralBond = new String(new char[2 * (n - n / 2) - 4]).replace("\0", "_");
- String centralSpace = centralBond.replace("_", " ");
- int width = 2 * columnTop.length() + centralBond.length() - 2;
- System.out.println(columnTop + centralBond + columnTop);
- for (int row = 0; row < n - 2; row++)
- {
- System.out.print("|");
- for (int col = 0; col < width; col++) {
- System.out.print(" ");
- if (row == n - 3 && col == n / 2) {
- System.out.print(centralBond);
- col += centralBond.length();
- }
- }
- System.out.println("|");
- }
- System.out.println(columnBottom + centralSpace + columnBottom);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment