题解 | #计算某字符出现次数#

计算某字符出现次数

http://www.nowcoder.com/practice/a35ce98431874e3a820dbe4b2d0508b1

use std::io;

pub fn main() { let mut s = String::new();

let mut c = String::new();
io::stdin()
    .read_line(&mut s)
    .expect("Fail to read this line!");

io::stdin()
    .read_line(&mut c)
    .expect("Fail to read this line!");

// println!("string is {}, char is {}", s, c);

// Count all the chars use lowercase let s = String::from(s.to_ascii_lowercase().trim()); let c = String::from(c.to_ascii_lowercase().trim()); let mut count: u32 = 0; for i in s.chars() { for j in c.chars() { if i == j { count += 1; } } }

println!("{}", count);

}

全部评论

相关推荐

我也曾抱有希望:说的好直白
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务