반응형
- 화씨와 섭씨를 상호 변환.
- n번째 피보나치 수열 생성.
- 크리스마스 캐롤 “The Twelve Days of Christmas”의 가사를 반복문을 활용해 출력.
이 3가지를 만들어보라고 해서 마지막 세번째인 가사 출력을 구현하였다.
fn main() {
let lyrics = [
"On the first day of Christmas",
"My good friends brought to me",
"A song and a Christmas tree",
"On the second day of Christmas",
"My good friends brought to me",
"Two candy canes",
"And a song for the Christmas tree",
"On the third day of Christmas",
"My good friends brought to me",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the fourth day of Christmas",
"My good friends brought to me",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the fifth day of Christmas",
"My good friends brought to me",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the sixth day of Christmas",
"My good friends brought to me",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the seventh day of Christmas",
"My good friends brought to me",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the eighth day of Christmas",
"My good friends brought to me",
"Gold and silver tinsel",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the ninth day of Christmas",
"My good friends brought to me",
"A guardian angel",
"Gold and silver tinsel",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the tenth day of Christmas",
"My good friends brought to me",
"Some mistletoe",
"A guardian angel",
"Gold and silver tinsel",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the 11th day of Christmas",
"My good friends brought to me",
"Gifts for one and all",
"Some mistletoe",
"A guardian angel",
"Gold and silver tinsel",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree",
"On the 12th day of Christmas",
"My good friends brought to me",
"All their good wishes",
"Gifts for one and all",
"Some mistletoe",
"A guardian angel",
"Gold and silver tinsel",
"Candles a-glowing",
"Little silver bells",
"A shining star",
"Four colored lights",
"Three boughs of holly",
"Two candy canes",
"And a song for the Christmas tree"
];
for element in lyrics.iter() {
println!("{}", element);
}
}
아마 이렇게 구현하라는게 아니였을까 생각한다.
for문 연습문제였다.
반응형
'Rust > Rust 개발' 카테고리의 다른 글
Rust - 피보나치 수열 (0) | 2022.04.29 |
---|---|
Rust - 화씨 섭씨 변환 (0) | 2022.04.28 |
최근댓글