Baekjoon Algorithm | Problem 2438: Print Stars - 1

Source

https://www.acmicpc.net/problem/2438

Problem

Solve Baekjoon Online Judge problem 2438, Print Stars - 1.

Input

Follow the input format and constraints given in the original problem statement.

Output

Print the answer required by the problem.

Sample Input 1

5

Sample Output 1

\* \** \*** \**** \*****

Algorithm Classification

  • Implementation

Solution

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            int input = Integer.parseInt(br.readLine());

            String star = "";
            for (int i = 0; i < input; i++) {
                star = star + "*";
                System.out.println(star);
            }
        }
    }
}