Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package draw;
- 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());
- int width = 2 * n;
- int carpet = n / 2;
- String line = "/" +
- repeatStr("^", n / 2) +
- "\\" +
- repeatStr("_", width - 4 - 2 * (n / 2)) +
- "/" +
- repeatStr("^", n / 2) +
- "\\";
- System.out.println(line);
- for (int i = 0; i < n - 2; i++) {
- String middleLine = "|" + repeatStr(" ", width - 2) + "|";
- if (i == n - 3) {
- middleLine = "|" +
- repeatStr(" ", (n / 2) + 1) +
- repeatStr("_", width - 4 - 2 * (n / 2)) +
- repeatStr(" ", (n / 2) + 1) +
- "|";
- }
- System.out.println(middleLine);
- }
- String lineLast = "\\" +
- repeatStr("_", n / 2) +
- "/" +
- repeatStr(" ", width - 4 - 2 * (n / 2)) +
- "\\" +
- repeatStr("_", n / 2) +
- "/";
- System.out.println(lineLast);
- }
- public static String repeatStr (String toRepeat, int count) {
- String text = "";
- for (int i = 0; i < count; i++) {
- text += toRepeat;
- }
- return text;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement