题解 | 牛牛的字符菱形

牛牛的字符菱形

https://www.nowcoder.com/practice/11a5040fa894430f9d25fda1be37ddc8

use std::io::{self, *};

fn main() {
    let stdin = io::stdin();
    let mut input = String::new();
    stdin.read_line(&mut input).unwrap();
    let nums:[usize;5] = [2, 1, 0, 1, 2];
    for i in  &nums{
        println!(
            "{}{}",
            String::from(" ").repeat(*i),
            input.trim().repeat(5 - *i * 2)
        );
    }
}

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务