题解 | #统计字符#

统计字符

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

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int count[128];
int main(){
    string str1,str2;
    while(getline(cin,str1)){
        if(str1=="#"){
            break;
        }
        getline(cin,str2);
        for(int i=0;i<128;++i){
            count[i]=0;
        }
        for(int i=0;i<str2.size();++i){
            ++count[str2[i]];
        }
        for(int i=0;i<str1.size();++i){
            cout<<str1[i]<<" "<<count[str1[i]]<<endl;
        }
    }
    return 0;
}

全部评论

相关推荐

2025-12-19 15:04
门头沟学院 Java
小肥罗:hr爱上你了,你负责吗哈哈
点赞 评论 收藏
分享
面了100年面试不知...:小天才g了,但是天才还在
投递小天才等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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