Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_26_March_2016 - created by borkins on 2017-05-14.
- */
- import java.util.Scanner;
- public class _05_Butterfly
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int n = Integer.parseInt(console.nextLine());
- int rows = 2 * (n - 2) + 1;
- String stars = new String(new char[n - 2]).replace("\0", "*");
- String dashes = new String(new char[n - 2]).replace("\0", "-");
- String wingsOfStars = stars + "\\ " + "/" + stars;
- String wingsOfDashes = dashes + "\\ " + "/" + dashes;
- for (int row = 0; row < rows; row++)
- {
- if (row == rows / 2)
- {
- for (int col = 0; col < n - 1; col++) {
- System.out.print(" ");
- }
- System.out.println("@");
- continue;
- }
- if (row % 2 == 0)
- {
- if (row < rows / 2) {
- System.out.println(wingsOfStars);
- }
- else {
- System.out.println(new StringBuilder(wingsOfStars).reverse());
- }
- }
- else
- {
- if (row < rows / 2) {
- System.out.println(wingsOfDashes);
- }
- else {
- System.out.println(new StringBuilder(wingsOfDashes).reverse());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment