728x90
https://www.acmicpc.net/problem/2523
2523번: 별 찍기 - 13
첫째 줄부터 2×N-1번째 줄까지 차례대로 별을 출력한다.
www.acmicpc.net
[문제]
[코드]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for(int i = 0; i < N; i++) {
for(int j = 0; j < i+1; j++)
System.out.print("*");
System.out.println();
}
for(int i = 0; i < N-1; i++) {
for(int j = 0; j < N-1-i; j++)
System.out.print("*");
System.out.println();
}
sc.close();
}
}
[결과]
728x90
'백준(Baekjoon)' 카테고리의 다른 글
[백준] 2577번: 숫자의 개수 - 자바 (0) | 2022.05.17 |
---|---|
[백준] 10872번: 팩토리얼 - 자바 (0) | 2022.05.16 |
[백준] 2884번: 알람 시계 - 자바 (0) | 2022.05.10 |
[백준] 5086번: 배수와 약수 - 자바 (0) | 2022.05.09 |
[백준] 2747번: 피보나치 수 - 자바 (0) | 2022.05.08 |