본문 바로가기
IT

[Rust] 99병의 맥주

by %? 2022. 6. 23.

fn main() {
    print!("99 bottles of beer on the wall, 99 bottles of beer. Take one down and pass it around, 98 bottles of beer on the wall.\n");

    for i in (1..99).rev()
    {
        if i == 2
        {
            print!("2 bottles of beer on the wall, 2 bottles of beer. Take one down and pass it around, 1 bottle of beer on the wall.\n");
        }
        else
        {
            print!("{} bottles of beer on the wall, {} bottles of beer. Take one down and pass it around, {} bottles of beer on the wall.\n", i, i, i-1);
        }
    }

    print!("1 bottle of beer on the wall, 1 bottle of beer. Take it down and pass it around, no more bottles of beer on the wall.\nNo more bottles of beer on the wall, no more bottles of beer.Go to the store and buy some more, 99 bottles of beer on the wall.\n");
}

요새 C/C++이나 Java, Python 말고 다른 언어도 해보고 있는데 Swift는 대화형 언어라서 Python이랑 비슷한 느낌으로 어려운데... Rust는 언어가 엄격해서 그런지 얘 자체가 엄청 어렵네요;;