https://www.acmicpc.net/problem/10994
첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다.
n일 때 배열의 가로,세로 크기는 4*(n-1)+1이다.
바깥 테두리부터 채워나간다고 생각하면 된다.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class star_10994 {
public static void solution() throws IOException{
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(bf.readLine());
int max = 4*(n-1)+1;
int count = 2*n-1;
char arr[][] = new char[max][max];
for(int i=0;i<count;i++){
if(i%2==0){
for(int j=i;j<max;j++){
for(int k=i;k<max;k++){
if(j==i || k==i || j==max-1 || k==max-1){
arr[j][k]='*';
}
}
}
}
else if(i%2!=0){
for(int j=i;j<max;j++){
for(int k=i;k<max;k++){
if(j==i || k==i || j==max-1 || k==max-1){
arr[j][k]=' ';
}
}
}
}
max = max-1;
}
for(int j=0;j<4*(n-1)+1;j++){
for(int k=0;k<4*(n-1)+1;k++){
System.out.print(arr[j][k]);
}
System.out.println();
}
}
}