Advertisement
16120

5.1

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