10996번
문제
- 예제를 보고 규칙을 유추한 다음에 별을 찍는 문제
- 예제 링크
문제 해결 순서
- 총
n*2번 반복하면서n만큼 출력하는데 별과 공백을 번갈아 출력하는 규칙 - 홀수 줄은 별 먼저, 짝수 줄에는 공백 먼저 출력
(1차 삽질 다른 경우는 다 이해되는데 1인 경우 별 하나 출력되는게 무슨 규칙인지 모르겠음.. 그냥 예외처리 함)`java import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt();
if(n == 1){ System.out.print("*"); return; }
for(int i = 1; i <= n2; i++){ for(int j = 1; j <= n; j++){ if(i % 2 == 1 && j % 2 == 1){ System.out.print(""); } else if(i % 2 == 1 && j % 2 == 0){ System.out.print(" "); } else if(i % 2 == 0 && j % 2 == 0){ System.out.print("*"); } else{ System.out.print(" "); } } System.out.print("n"); } } }

