[Rust로 백준 하루 하나] 3-9. 별 찍기 - 1

김진산·2024년 8월 10일

Rust로 백준 하루 하나

목록 보기
29/138
post-thumbnail

문제 (2438번)

첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제

입력

첫째 줄에 N(1 ≤ N ≤ 100)이 주어진다.

출력

첫째 줄부터 N번째 줄까지 차례대로 별을 출력한다.


풀이

코드

use std::io;

fn main() {
    let mut input = String::new();
    
    io::stdin()
        .read_line(&mut input)
        .expect("Cannot read line.");
    
    let input: usize = input.trim().parse().unwrap();
    
    for i in 1..=input {
        println!("{}", "*".repeat(i));
    }
}

해설

특이사항 없음


추가 학습

  • 특이사항 없음
profile
블록체인 개발자

0개의 댓글