import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int input = new Scanner(System.in).nextInt();
main(input);
}
public static void main(int input) {
String str = "";
for(int i = 0; i < input; i++) {
for(int j = 1; j<= input; j++) {
if(j == 1) {
str += "*";
} else if (input == 2) {
str += "\n *";
}else if(input % 2 == 0 && j == input / 2) {
str += " *\n";
} else if (input % 2 != 0 && j == (input / 2) + 1) {
str += " *\n";
} else {
str += " *";
}
}
str += "\n";
}
System.out.print(str);
}
}
좋지 않은 풀이
더 좋은 풀이를 생각해봐야겠다.
'공부 스걱스걱 > 코딩테스트' 카테고리의 다른 글
[백준] 1475번_방번호 (0) | 2022.01.12 |
---|---|
[python3] 프로그래머스_숫자 문자열과 영단어 (0) | 2021.09.10 |
[python3] 프로그래머스_기능개발 (0) | 2021.07.02 |
[python3] 프로그래머스_전화번호 목록 (0) | 2021.06.24 |
[python3]프로그래머스_내적 (0) | 2021.05.21 |