complete twelve days of christmas
This commit is contained in:
Generated
+4
@@ -20,6 +20,10 @@ version = "0.1.0"
|
||||
name = "common-programming-concepts-temp-converter"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "common-programming-concepts-twelve-days-of-christmas"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.17"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
[workspace]
|
||||
members = ["common-programming-concepts", "common-programming-concepts-fibonacci", "common-programming-concepts-temp-converter","guessing-game"]
|
||||
members = ["common-programming-concepts", "common-programming-concepts-fibonacci", "common-programming-concepts-temp-converter", "common-programming-concepts-twelve-days-of-christmas","guessing-game"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "common-programming-concepts-twelve-days-of-christmas"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
@@ -0,0 +1,25 @@
|
||||
fn main() {
|
||||
let gifts: [&str;12] = ["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 mut s = String::from(gifts[0]);
|
||||
|
||||
for day in 1..13 {
|
||||
let ending = if day == 1 {
|
||||
"st"
|
||||
} else if day == 2 {
|
||||
"nd"
|
||||
} else {
|
||||
"th"
|
||||
};
|
||||
println!("\nOn the {day}{ending} day of Christmas, my true love sent to me");
|
||||
println!("{s}");
|
||||
|
||||
if day != 12 {
|
||||
s.insert_str(0,"\n");
|
||||
s.insert_str(0,gifts[day]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user