Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 2
- 5 2 #
- 11 1 !
- # # # #
- ## ## ## ##
- # #[]# # # #[]# #
- ## ## ## ##
- # # # #
- ! !
- !! !!
- ! ! ! !
- ! ! ! !
- ! ! ! !
- ! ![]! !
- ! ! ! !
- ! ! ! !
- ! ! ! !
- !! !!
- ! !
- import java.util.*;
- public class Main
- {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- int sets, width, bowties, length, intspaces, extspaces, mid, counter;
- char mat;
- sets = in.nextInt();
- for(int i = 1; i <= sets; i++)
- {
- length = in.nextInt();
- bowties = in.nextInt();
- mat = in.next().charAt(0);
- width = length + 3;
- mid = length/2 + 1;
- counter = 2;
- String[] out = new String[length];
- for(int x = 0; x < mid; x++)
- {
- if(x == 0)
- {
- intspaces = width - 2;
- String intspace = space(intspaces, length);
- out[x] = mat + intspace + mat;
- }
- else if(x != (mid-1))
- {
- intspaces = width - 2 * (x + 1);
- extspaces = x - 1;
- String intspace = space(intspaces, length);
- String extspace = space(extspaces, length);
- out[x] = mat + extspace + mat + intspace + mat + extspace + mat;
- }
- else
- {
- extspaces = x - 1;
- String extspace = space(extspaces, length);
- out[x] = mat + extspace + mat + "[]" + mat + extspace + mat;
- }
- }
- for(int x = mid; x < length; x++)
- {
- int count = x - counter;
- out[x] = out[count];
- counter += 2;
- }
- if(bowties != 1)
- {
- stringMulti(out, length, width, bowties);
- }
- for(int x = 0; x < length; x++)
- {
- System.out.println(out[x]);
- }
- System.out.println();
- }
- }
- public static String space(int spaces, int length)
- {
- StringBuilder sb = new StringBuilder(length - 2);
- for(int i = 1; i <= spaces; i++)
- {
- sb.append(" ");
- }
- return sb.toString();
- }
- public static void stringMulti(String out[], int length, int width, int sets)
- {
- for(int x = 0; x < length; x++)
- {
- StringBuilder sb = new StringBuilder(width + sets * (width + 1));
- sb.append(out[x]);
- for(int y = 1; y < sets; y++)
- {
- sb.append(" ");
- sb.append(out[x]);
- }
- out[x] = sb.toString();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement