Advertisement
16112

5.1 Чертане на крепост

Dec 16th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package kursova_rabota;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class pet_edno {
  6.     static String repeatStr(String strToRepeat, int count) {
  7.         String text = " ";
  8.         for (int i = 0; i < count; i++) {
  9.             text = text + strToRepeat;
  10.         }
  11.         return text;
  12.     }
  13.  
  14.     public static void main(String[] args) {
  15.  
  16.         Scanner sc = new Scanner(System.in);
  17.         int n = Integer.parseInt(sc.nextLine());
  18.         int col = n / 2;
  19.         int mid = 2 * n - 2 * col - 4;
  20.  
  21.         String undersc = repeatStr("_", mid);
  22.         String arrow = repeatStr("^", col);
  23.  
  24.         System.out.println(String.format("/%s\\%s/%s\\", arrow, undersc, arrow));
  25.         for (int row = 1; row <= n - 3; row++) {
  26.             System.out.println(String.format("|%s|", repeatStr(" ", 2 * n)));
  27.         }
  28.         String sspace = repeatStr(" ", col + 1);
  29.         System.out.println(String.format("|%s%s%s|", sspace, undersc, sspace));
  30.         String mspace = repeatStr(" ", mid);
  31.         undersc = repeatStr("_", col);
  32.         System.out.println(String.format("\\%s/%s\\%s/", undersc, mspace, undersc));
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement