-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rs
46 lines (39 loc) · 1.2 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Print the lyrics to the Christmas carol “The Twelve Days of Christmas,”
taking advantage of the repetition in the song.
*/
fn main() {
let lines = ["A partridge in a pear tree",
"Two turtle doves, and",
"Three french hens",
"Four calling birds",
"Five golden rings",
"Six geese a-laying",
"Seven swans a-swimming",
"Eight maids a-milking",
"Nine ladies dancing",
"Ten lords a-leaping",
"Eleven pipers piping",
"Twelve drummers drumming"];
let days = ["first",
"second",
"thrid",
"fourth",
"fifth",
"sixth",
"seventh",
"eighth",
"ninth",
"tenth",
"eleventh",
"twelfth"];
let mut count = 0;
for day in days {
println!("On the {} day of Christmas, my true love sent to me", day);
count += 1;
for i in (0..count).rev() {
println!("{}", lines[i]);
}
println!("");
}
}