OpKaTa

MENTORMATE FINAL

Feb 11th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ProbiforWork {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scan.nextLine());
  8.  
  9. String stars = "*";
  10. String minus = "-";
  11. getFirstLine(n, stars, minus);
  12. System.out.println();
  13. getFirsCenterLines(n, stars, minus);
  14. getSecondsCenterLines(n, stars, minus);
  15. //
  16. getLastLine(n, stars, minus);
  17.  
  18.  
  19. }
  20.  
  21. private static void getSecondsCenterLines(int n, String stars, String minus) {
  22.  
  23. // tova sa poslednite redove bez posledniq
  24. int lines = (n - 1) / 2;
  25.  
  26. int value = n / 2;
  27. int firstAndLastMinus = (int) Math.ceil(value);
  28.  
  29. int minusForMakingM = 1;
  30.  
  31. int aLotOfStars = n+((n-1));
  32.  
  33.  
  34. for (int i = 1; i <= lines; i++) {
  35.  
  36. for (int j = 1; j <= 2; j++) {
  37. for (int k = 1; k <= firstAndLastMinus; k++) {
  38. System.out.print(minus);
  39. }
  40. for (int k = 1; k <= n; k++) {
  41. System.out.print(stars);
  42. }
  43. for (int k = 1; k <=minusForMakingM; k++) {
  44. System.out.print(minus);
  45. }
  46. for (int k = 1; k <=aLotOfStars; k++) {// dapomislq mnogoto tochki
  47. System.out.print(stars);
  48. }
  49. for (int k = 1; k <=minusForMakingM ; k++) {
  50. System.out.print(minus);
  51. }
  52. for (int k = 1; k <= n; k++) {
  53. System.out.print(stars);
  54. }
  55. for (int k = 1; k <= firstAndLastMinus; k++) {
  56. System.out.print(minus);
  57. }
  58.  
  59. }
  60. firstAndLastMinus -=1;
  61. minusForMakingM +=2;
  62. aLotOfStars -=2;
  63. System.out.println();
  64. }
  65.  
  66. }
  67.  
  68. private static void getFirsCenterLines(int n, String stars, String minus) {
  69. int lines = ((n-1)/2);
  70.  
  71. int startEndLines = n;
  72. int firstStar = n;
  73. int midMinus=n;
  74.  
  75.  
  76. for (int i = 1; i <=lines ; i++) {
  77. startEndLines -=1;
  78. firstStar +=2;
  79. midMinus -=2;
  80. for (int colum = 1; colum <=2; colum++) {
  81.  
  82. for (int j = 1; j <= startEndLines; j++) { //purvite minusi
  83. System.out.print(minus);
  84. }
  85. for (int j = 1; j <=firstStar; j++) {
  86. System.out.print(stars);
  87. }
  88. for (int j = 1; j <=midMinus; j++) {
  89. System.out.print(minus);
  90. }
  91. for (int j = 1; j <=firstStar ; j++) {
  92. System.out.print(stars);
  93. }
  94. for (int j = 1; j <=startEndLines ; j++) {
  95. System.out.print(minus);
  96. }
  97.  
  98. }
  99. System.out.println();
  100.  
  101. }
  102.  
  103.  
  104. }
  105.  
  106.  
  107.  
  108.  
  109. private static void getLastLine(int n, String stars, String minus) {
  110. for (int i = 1; i <= 5; i++) {
  111. for (int j = 1; j <= n; j++) {
  112. System.out.print(stars);
  113. }
  114. if (i == 3) {
  115. continue;
  116. }
  117. for (int j = 1; j <= n; j++) {
  118. System.out.print(minus);
  119. }
  120. if (i == 5) {
  121. for (int j = 1; j <= n; j++) {
  122. System.out.print(stars);
  123. }
  124. }
  125. }
  126. }
  127.  
  128. private static void getFirstLine(int n, String stars, String minus) {
  129.  
  130. for (int i = 1; i <= 5; i++) {
  131. for (int j = 1; j <= n; j++) {
  132. System.out.print(minus);
  133. }
  134. if (i == 3) {
  135. continue;
  136. }
  137. for (int j = 1; j <= n; j++) {
  138. System.out.print(stars);
  139. }
  140. if (i == 5) {
  141. for (int j = 1; j <= n; j++) {
  142. System.out.print(minus);
  143. }
  144. }
  145.  
  146. }
  147.  
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment