Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Butterfly {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int row = 0; row < n - 2; row++) {
  10.           if(row % 2 == 0){
  11.             System.out.print(repeatStr("*", n - 2));
  12.             System.out.print("\\");
  13.             System.out.print(" ");
  14.             System.out.print("/");
  15.             System.out.println(repeatStr("*", n - 2));
  16.           }else{
  17.             System.out.print(repeatStr("-", n - 2));
  18.             System.out.print("\\");
  19.             System.out.print(" ");
  20.             System.out.print("/");
  21.             System.out.println(repeatStr("-", n - 2));
  22.           }
  23.         }
  24.  
  25.         System.out.print(repeatStr(" ", n-1));
  26.         System.out.println("@");
  27.  
  28.         for (int row = 0; row < n - 2; row++){
  29.           if(row % 2 == 0){
  30.             System.out.print(repeatStr("*", n - 2));
  31.             System.out.print("/");
  32.             System.out.print(" ");
  33.             System.out.print("\\");
  34.             System.out.println(repeatStr("*", n -2));
  35.           }else{
  36.             System.out.print(repeatStr("-", n - 2));
  37.             System.out.print("/");
  38.             System.out.print(" ");
  39.             System.out.print("\\");
  40.             System.out.println(repeatStr("-", n - 2));
  41.           }
  42.         }
  43.     }
  44.     static String repeatStr(String strToRepeat, int count) {
  45.         String text = "";
  46.  
  47.         for (int i = 0; i < count; i++) {
  48.             text = text + strToRepeat;
  49.         }
  50.  
  51.         return text;
  52.     }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement