Advertisement
desislava_topuzakova

05.Butterfly

Mar 11th, 2018
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Butterfly1 {
  4. public static void main(String[] agrs) {
  5. Scanner scanner = new Scanner(System.in);
  6. int n = Integer.parseInt(scanner.nextLine());
  7.  
  8. int weight = 4 * n - 4;
  9.  
  10. for (int i = 1; i <= n - 2; i++) {//up wing
  11. String upWing = repeatStr("*\\", i) +
  12. repeatStr(" ", weight - 4 * i) +
  13. repeatStr("/*", i);
  14. System.out.println(upWing);
  15. }
  16.  
  17. String up = repeatStr("\\/", weight / 2);
  18. String down = repeatStr("/\\", weight / 2);
  19.  
  20. System.out.println(up);//up to middle part
  21.  
  22. for (int i = 0; i < n / 2; i++) {//middle part
  23. String middleRow = repeatStr("<", (weight - 6) / 2) +
  24. "*|**|*" + repeatStr(">", (weight - 6) / 2);
  25. System.out.println(middleRow);
  26. }
  27. System.out.println(down);//down to middle part
  28.  
  29. for (int i = 0; i < n - 2; i++) {//down wing
  30. String downWing = repeatStr("*/", (weight - 4) / 4 - i) +
  31. repeatStr(" ", 4 + 4 * i)
  32. + repeatStr("\\*", (weight - 4) / 4 - i);
  33. System.out.println(downWing);
  34.  
  35. }
  36. }
  37.  
  38. static String repeatStr(String str, int count) {
  39. String text = "";
  40. {
  41. for (int j = 0; j < count; j++) {
  42. text = text + str;
  43. }
  44.  
  45. }
  46. return text;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement