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

计算某字符出现次数

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);

}

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 15:08
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-10 14:00
林子大了什么鸟都有啊,我觉得我说的已经很客气了,阴阳谁呢
牛客62656195...:应该不是阴阳吧?你第一次注册的时候boss就说你是牛人
点赞 评论 收藏
分享
06-07 12:20
新余学院 Java
点赞 评论 收藏
分享
不要停下啊:大二打开牛客,你有机会开卷了,卷起来,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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