题解 | #字符数量#

字符数量

https://ac.nowcoder.com/acm/problem/22225

using namespace std;
#define int long long
#define endl '\n'
signed main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    char m;int count[100000];//数组要设置得大一点,不然就会错误了
        while(cin>>m&&m!=EOF)
        {
            if(m>='a'&&m<='z')
             count[m]++;//如果是小写就记录++
        }
       
    for(char i='a';i<='z';i++){
        if(count[i]!=0){
            cout<<i<<":"<<count[i]<<endl;
        }
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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