Advertisement
Guest User

Untitled

a guest
Oct 12th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. 2
  2. 5 2 #
  3. 11 1 !
  4.  
  5. # # # #
  6. ## ## ## ##
  7. # #[]# # # #[]# #
  8. ## ## ## ##
  9. # # # #
  10.  
  11. ! !
  12. !! !!
  13. ! ! ! !
  14. ! ! ! !
  15. ! ! ! !
  16. ! ![]! !
  17. ! ! ! !
  18. ! ! ! !
  19. ! ! ! !
  20. !! !!
  21. ! !
  22.  
  23. import java.util.*;
  24.  
  25. public class Main
  26. {
  27. public static void main(String[] args)
  28. {
  29. Scanner in = new Scanner(System.in);
  30.  
  31. int sets, width, bowties, length, intspaces, extspaces, mid, counter;
  32. char mat;
  33.  
  34. sets = in.nextInt();
  35. for(int i = 1; i <= sets; i++)
  36. {
  37. length = in.nextInt();
  38. bowties = in.nextInt();
  39. mat = in.next().charAt(0);
  40. width = length + 3;
  41. mid = length/2 + 1;
  42. counter = 2;
  43. String[] out = new String[length];
  44.  
  45.  
  46. for(int x = 0; x < mid; x++)
  47. {
  48. if(x == 0)
  49. {
  50. intspaces = width - 2;
  51. String intspace = space(intspaces, length);
  52. out[x] = mat + intspace + mat;
  53. }
  54. else if(x != (mid-1))
  55. {
  56. intspaces = width - 2 * (x + 1);
  57. extspaces = x - 1;
  58. String intspace = space(intspaces, length);
  59. String extspace = space(extspaces, length);
  60. out[x] = mat + extspace + mat + intspace + mat + extspace + mat;
  61. }
  62. else
  63. {
  64. extspaces = x - 1;
  65. String extspace = space(extspaces, length);
  66. out[x] = mat + extspace + mat + "[]" + mat + extspace + mat;
  67. }
  68. }
  69.  
  70. for(int x = mid; x < length; x++)
  71. {
  72. int count = x - counter;
  73. out[x] = out[count];
  74. counter += 2;
  75. }
  76.  
  77. if(bowties != 1)
  78. {
  79. stringMulti(out, length, width, bowties);
  80. }
  81.  
  82. for(int x = 0; x < length; x++)
  83. {
  84. System.out.println(out[x]);
  85. }
  86. System.out.println();
  87.  
  88. }
  89. }
  90. public static String space(int spaces, int length)
  91. {
  92. StringBuilder sb = new StringBuilder(length - 2);
  93. for(int i = 1; i <= spaces; i++)
  94. {
  95. sb.append(" ");
  96. }
  97. return sb.toString();
  98. }
  99.  
  100. public static void stringMulti(String out[], int length, int width, int sets)
  101. {
  102. for(int x = 0; x < length; x++)
  103. {
  104. StringBuilder sb = new StringBuilder(width + sets * (width + 1));
  105. sb.append(out[x]);
  106. for(int y = 1; y < sets; y++)
  107. {
  108. sb.append(" ");
  109. sb.append(out[x]);
  110. }
  111. out[x] = sb.toString();
  112. }
  113.  
  114. }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement