Problem:
첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제. 첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다.
My Code:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class BaekJoon_2438 {
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());
br.close();
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
bw.write("*");
}
bw.newLine();
}
bw.flush();
bw.close();
}
}
Input
5
Output
*
**
***
****
*****