반응형

1. 문제 번호 2439번


 

2. 문제 풀이 

 - 

나의 문제풀이 방식 및 순서

 - 다중 반복문이 좋은 선택인지는 잘 모르겠다.


3. 소스 인증

import java.util.*;
import java.lang.*;
import java.io.*;

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));
        StringTokenizer st = new StringTokenizer(br.readLine());
        
        int cnt = Integer.parseInt(st.nextToken());
        
        for(int i = 1; i <= cnt; i++){
            // 공백 출력
            for(int j = cnt; j > i; j--){
                bw.write(" ");    
            }
            // 별표 출력
            for(int k = 1; k <= i; k++){
                bw.write("*");
            }
            // 줄 바꿈
            bw.write("\n");
        }
        bw.flush();   //남아있는 데이터를 모두 출력시킴
        bw.close();   //스트림을 닫음
    }
}

4. 추가 개념

728x90
반응형

'알고리즘(BOJ) 문제풀이' 카테고리의 다른 글

[BOJ/백준] 반복문_10951번  (0) 2024.05.09
[BOJ/백준] 반복문_10952번  (0) 2024.05.08
[BOJ/백준] 반복문_2438번  (0) 2024.05.08
[BOJ/백준] 반복문_11022번  (0) 2024.05.08
[BOJ/백준] 반복문_11021번  (0) 2024.05.08

+ Recent posts