题解 | #统计字符#

统计字符

https://www.nowcoder.com/practice/4ec4325634634193a7cd6798037697a8

#include<iostream>
#include<string>
// #include<vector>
// #include<cmath>
// #include<algorithm>
using namespace std;

int main(){
    string s1,s2;
    while(getline(cin,s1)&&s1!="#"){
        //cin.get();
        getline(cin,s2);
        for(int i=0;i<s1.length();i++){
            int k=0;
            for(int j=0;j<s2.length();j++){
                if(s2[j]==s1[i])
                    k++;
            }
        cout<<s1[i]<<' '<<k<<endl;
        }
    }
}

主要是利用getline读取

全部评论

相关推荐

06-04 09:27
门头沟学院 Java
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 14:23
steelhead:你回的有问题,让人感觉你就是来学习的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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