Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by entropy on 4/19/2017.
- */
- import java.util.Scanner;
- public class stronghold {
- public static void main(String[] args) {
- Scanner scanner = new Scanner (System.in);
- int n = Integer.parseInt(scanner.nextLine());
- if (n>4){
- String top = "/"+repeatString("^", n/2)+"\\"+repeatString("_", n/2)+"/"+repeatString("^", n/2)+"\\";
- System.out.println(top);}
- else {
- String top = "/"+repeatString("^", n/2)+"\\"+"/"+repeatString("^", n/2)+"\\";
- System.out.println(top);}
- if (n>4) {
- for (int i = 0; i < n - 3; i++) {
- String middle = "|" + repeatString(" ", 2 * n - 2) + ("|");
- System.out.println(middle);
- }
- } else {for (int i = 0; i < n - 2; i++) {
- String middle = "|" + repeatString(" ", 2 * n - 2) + ("|");
- System.out.println(middle);
- }
- }
- if (n>4){
- String topBottom ="|"+repeatString(" ",n/2+1)+repeatString("_", n/2)+repeatString(" ", n/2+1)+"|";
- System.out.println(topBottom);
- String bottom = "\\"+repeatString("_", n/2)+"/"+repeatString(" ", n/2)+"\\"+repeatString("_", n/2)+"/";
- System.out.println(bottom);}
- else {
- String bottom = "\\"+repeatString("_", n/2)+"/"+"\\"+repeatString("_", n/2)+"/";
- System.out.println(bottom);}
- } public static String repeatString (String str, int count) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i <count ; i++) {
- sb.append(str);
- }
- return sb.toString();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement