Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TestTask2New {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- if (n % 2 == 0) {
- String firstRow = "/" + repeatStr("^", n / 2) + "\\" + repeatStr("_", n - 4)
- + "/" + repeatStr("^", n / 2) + "\\";
- System.out.println(firstRow);
- } else {
- System.out.println("/" + repeatStr("^", n / 2) + "\\" + repeatStr("_", n - 3)
- + "/" + repeatStr("^", n / 2) + "\\");
- }
- for (int i = 0; i < n - 3; i++) {
- String middleRows = "|" + repeatStr(" ", 2 * n - 2) + "|";
- System.out.println(middleRows);
- }
- if (n % 2 == 0) {
- String rowBeforeLast = "|" + repeatStr(" ", n / 2 + 1)
- + repeatStr("_", n - 4) + repeatStr(" ", n / 2 + 1) + "|";
- System.out.println(rowBeforeLast);
- } else {
- System.out.println("|" + repeatStr(" ", n / 2 + 1)
- + repeatStr("_", n - 3) + repeatStr(" ", n / 2 + 1) + "|");
- }
- if (n % 2 == 0) {
- String lastRow = "\\" + repeatStr("_", n / 2) + "/"
- + repeatStr(" ", n - 4) + "\\" + repeatStr("_", n / 2)
- + "/";
- System.out.println(lastRow);
- }else {
- System.out.println("\\" + repeatStr("_", n / 2) + "/"
- + repeatStr(" ", n - 3) + "\\" + 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