Advertisement
paykova

Crown

Oct 24th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Crown {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. int b = 2* ((2*n - 1)/3 - 2 ) -1;
  9.  
  10. String firstLine = "@"
  11. + repeatStr(" ", n - 2)
  12. + "@"
  13. + repeatStr(" ", n - 2)
  14. + "@";
  15. System.out.println(firstLine);
  16. String secondLine = "**"
  17. + repeatStr(" ", n - 3)
  18. + "*"
  19. + repeatStr(" ", n - 3)
  20. + "**";
  21. System.out.println(secondLine);
  22.  
  23. for (int i = 0; i < n / 2 - 2; i++) {
  24. String mainBody = "*"
  25. + repeatStr(".", 1 + i)
  26. + "*"
  27. + repeatStr(" ", (n -5) - 2 * i)
  28. + "*"
  29. + repeatStr(".", 1 + 2 * i)
  30. + "*"
  31. + repeatStr(" ", (n -5) - 2 * i)
  32. + "*"
  33. + repeatStr(".", 1 + i)
  34. + "*";
  35. System.out.println(mainBody);
  36. }
  37.  
  38. String line1 = "*"
  39. + repeatStr(".", (2 * n - 1) / 3 - 2)
  40. + "*"
  41. + repeatStr(".", b)
  42. + "*"
  43. + repeatStr(".", (2 * n - 1) / 3 - 2)
  44. + "*";
  45. System.out.println(line1);
  46.  
  47. String line2 = "*"
  48. + repeatStr(".", n / 2)
  49. + "*"
  50. + repeatStr("*", (n - 6) / 2)
  51. + "."
  52. + repeatStr("*", (n - 6) / 2)
  53. + "*"
  54. + repeatStr(".", n / 2)
  55. + "*";
  56. System.out.println(line2);
  57.  
  58.  
  59. String lastLines = repeatStr("*", 2 * n - 1);
  60. System.out.println(lastLines);
  61. System.out.println(lastLines);
  62. }
  63.  
  64. static String repeatStr(String strToRepeat, int count) {
  65. String text = "";
  66. for (int i = 0; i < count; i++) {
  67. text += strToRepeat;
  68. }
  69. return text;
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement