Advertisement
Guest User

Untitled

a guest
Oct 27th, 2021
20,035
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.98 KB | None | 0 0
  1. fn main() {
  2.     let days = ["first","second","third","fourth","fifth","sixth",
  3.                 "seventh", "eighth", "ninth", "tenth", "eleventh",
  4.                 "twelth"];
  5.     let presents = ["a partridge in a pear tree", "2 turtle doves",
  6.                     "3 french hens", "4 calling birds", "5 golden rings",
  7.                     "6 geese a laying", "7 swans a swimming",
  8.                     "8 maids a milking", "9 ladies dancing",
  9.                     "10 lords a leaping", "11 pipers piping",
  10.                     "12 drummers drumming"];
  11.  
  12.     for day in 0..12 {
  13.         println!("On the {} day of Christmas my true love gave to me...",
  14.                  days[day]);
  15.  
  16.         for p in (0..day+1).rev() {
  17.             if p == 0 {
  18.                 println!("  {}{}.", if day != 0 { "and " } else { "" },
  19.                          presents[p]);
  20.             } else {
  21.                 println!("  {},", presents[p]);
  22.             }  
  23.         }  
  24.         println!("");
  25.     }  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement