일기 대신 코드 슬쩍
[백준][JAVA] 2438번. 별 찍기-1 본문
문제
첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제
입력
첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다.
출력
첫째 줄부터 N번째 줄까지 차례대로 별을 출력한다.
예제 입력 1
5
예제 출력 1
*
**
***
****
*****
문제 풀이
import java.io.*;
public class 백준_2438번 {
class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
for(int i = 0; i < n; i++) {
for(int j=0;j<=i;j++) {
bw.write("*");
}
bw.write("\\n");
}
bw.flush();
bw.close();
bw.close();
}
}
}
'코딩테스트 > 백준(JAVA)' 카테고리의 다른 글
[백준][JAVA] 10952번. A+B - 5 (0) | 2024.05.15 |
---|---|
[백준][JAVA] 2439번. 별 찍기 -2 (0) | 2024.05.15 |
[백준][JAVA] 11022번. A+B-8 (0) | 2024.05.15 |
[백준][JAVA] 11021번. A+B-7 (0) | 2024.05.15 |
[백준][JAVA] 15552번. 빠른 A+B (1) | 2024.05.15 |