백준 #5354번 J박스

jhj·2024년 5월 28일

백준 JAVA

목록 보기
507/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] c = new int[n];
		for(int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
		}
		
		for(int i = 0; i < n; i++) {
			if(c[i] != 1) {
				for(int j = 0; j < c[i]; j++) {
					System.out.print("#");
				}
				System.out.println();
				int b = c[i] - 2;
				
				for(int k = 0; k < b; k++) {
					System.out.print("#");
					for(int j = 0; j < b; j++) {
						System.out.print("J");
					}
					System.out.println("#");
				}
				
				for(int j = 0; j < c[i]; j++) {
					System.out.print("#");
				}
				System.out.println();
				System.out.println();
			}else if(c[i] == 1) {
				System.out.println("#");
				System.out.println();
			}
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글