Advertisement
BetinaUKTC

arrow

Nov 12th, 2020
90
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.*;
  2.  
  3. class Main {
  4. public static String makeSymbols(String str, int num) {
  5. String symbol = "";
  6. int i = 0;
  7. while ( i < num) {
  8. symbol += str;
  9. i++;
  10. }
  11. return symbol;
  12. }
  13.  
  14. public static void arrow(int n) {
  15. //top line
  16. System.out.print(makeSymbols(".", n / 2));
  17. System.out.print(makeSymbols("#", n));
  18. System.out.println(makeSymbols(".", n / 2));
  19. // top
  20. int i = 1;
  21. while (i <= n - 2) {
  22. System.out.print(makeSymbols(".", n / 2) + "#");
  23. System.out.print(makeSymbols(".", n - 2));
  24. System.out.println("#" + makeSymbols(".", n / 2));
  25. i++;
  26. }
  27. // middle
  28. System.out.print("#" + makeSymbols("#", n / 2));
  29. System.out.print(makeSymbols(".", n - 2));
  30. System.out.println("#" + makeSymbols("#", n / 2));
  31. // bot
  32. int dots = 1;
  33. while (dots < n - 1) {
  34. System.out.print(makeSymbols(".", dots) + "#");
  35. System.out.print(makeSymbols(".", (n * 2 - 1) - dots * 2 - 2) + "#");
  36. System.out.println(makeSymbols(".",dots));
  37. dots++;
  38. }
  39. System.out.println(makeSymbols(".",dots) + "#" + makeSymbols(".",dots));
  40. }
  41.  
  42. public static void main(String[] args) {
  43. Scanner scan = new Scanner(System.in);
  44. int n = scan.nextInt();
  45. arrow(n);
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement