Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- if (n <= 4) {
- System.out.println("/"
- + repeatStr("^", n / 2) + "\\"
- + "/" + repeatStr("^", n / 2) + "\\");
- for (int i = 0; i < n / 2 ; i++) {
- System.out.println("|" + repeatStr(" ", 2 * n - 2) + "|");
- }
- System.out.println("\\"
- + repeatStr("_", n / 2) + "/"
- + "\\" + repeatStr("_", n / 2) + "/");
- } else {
- int formula = n * 2 - (n / 2 + 2) * 2;
- System.out.println("/"
- + repeatStr("^", n / 2) + "\\"
- + repeatStr("_", formula) + "/"
- + repeatStr("^", n / 2) + "\\");
- for (int i = 0; i < n - 3; i++) {
- System.out.println("|" + repeatStr(" ", n * 2 - 2) + "|");
- }
- System.out.println("|"
- + repeatStr(" ", n / 2 + 1)
- + repeatStr("_", formula)
- + repeatStr(" ", n / 2 + 1) + "|");
- System.out.println("\\"
- + repeatStr("_", n / 2) + "/"
- + repeatStr(" ", formula) + "\\"
- + repeatStr("_", n / 2) + "/");
- }
- }
- static String repeatStr(String strToRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text += strToRepeat;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement