zoukankan      html  css  js  c++  java
  • Rust打印The Twelve Days of christmas歌词

    1、网上搜了下歌词,歌词原文如下:

    The Twelve Days Of Christmas - Songtime Kids
    On the first day of Christmas
    My true love sent to me
    A partridge in a pear tree
    On the second day of Christmas
    My true love sent to me
    Two turtle doves
    And a partridge in a pear tree
    On the third day of Christmas
    My true love sent to me
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the fourth day of Christmas
    My true love sent to me
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the fifth day of Christmas
    My true love sent to me
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the sixth day of Christmas
    My true love sent to me
    Six geese a-laying
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the seventh day of Christmas
    My true love sent to me
    Seven swans a-swimming
    Six geese a-laying
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the eighth day of Christmas
    My true love sent to me
    Eight maids a-milking
    Seven swans a-swimming
    Six geese a-laying
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the ninth day of Christmas
    My true love sent to me
    Nine ladies dancing
    Eight maids a-milking
    Seven swans a-swimming
    Six geese a-laying
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the tenth day of Christmas
    My true love sent to me
    Ten Lords a Leaping
    Nine ladies dancing
    Eight maids a-milking
    Seven swans a-swimming
    Six geese a-laying
    Five gold rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the eveth day of Christmas
    My true love sent to me
    Eleven Pipers Piping
    Ten Lords a Leaping
    Nine ladies dancing
    Eight maids a-milking
    Seven swans a-swimming
    Six geese a-laying
    Five golden Rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree
    On the Twelve day of Christmas
    My true love sent to me
    Twelve Drummers Drumming
    Eleven Pipers Piping
    Ten Lords a Leaping
    Nine ladies dancing
    Eight maids a-milking
    Seven swans a-swimming
    Six geese a-laying
    Five golden Rings
    Four calling birds
    Three French hens
    Two turtle doves
    And a partridge in a pear tree

    2、分析一下歌词内容,大概需要嵌套循环来解决问题,代码如下:

    fn main() {
        let count = [
            "first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth",
            "tenth", "eveth", "Twelve",
        ];
    
        println!("The Twelve Days of christmas - Songtime Kids");
    
        for i in 0..count.len() {
            println!(
                "On the {} day of Christmas 
            
    My true love sent to me",
                count[i]
            );
            if i == 0 {
                println!("A partridge in a pear tree");
                continue;
            }
            for j in 0..=i {
                match i - j {
                    0 => println!("And a partridge in a pear tree"),
                    1 => println!("Two turtle doves"),
                    2 => println!("Three French hens"),
                    3 => println!("Four calling birds"),
                    4 => println!("Five golden Rings"),
                    5 => println!("Six geese a-laying"),
                    6 => println!("Seven swans a-swimming"),
                    7 => println!("Eight maids a-milking"),
                    8 => println!("Nine ladies dancing"),
                    9 => println!("Ten Lords a Leaping"),
                    10 => println!("Eleven Pipers Piping"),
                    11 => println!("Twelve Drummers Drumming"),
                    _ => (),
                }
            }
        }
    }
    

    3、欢迎勘误 End

  • 相关阅读:
    codeforces 19B Checkout Assistant DP
    bzoj1053: [HAOI2007]反素数ant [搜索]
    【2017泉州基地校集训】雷神领域[二分图][并查集]
    bzoj1433: [ZJOI2009]假期的宿舍 [二分图][二分图最大匹配]
    bzoj 1059: [ZJOI2007]矩阵游戏 [二分图][二分图最大匹配]
    二分图带权匹配-Kuhn-Munkres算法模板 [二分图带权匹配]
    luogu P1332 血色先锋队[bfs]
    匈牙利算法dfs模板 [二分图][二分图最大匹配]
    【2017泉州基地校集训】最优排名[贪心]
    最大流Dinic算法的一些优化 [网络流][最大流]
  • 原文地址:https://www.cnblogs.com/qisong/p/14516414.html
Copyright © 2011-2022 走看看