题解 | #统计字符#

统计字符

http://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5

#include<bits/stdc++.h>

using namespace std;

int main(){
    
    string str;
    while(getline(cin,str)){
        int a=0,kg=0,nums=0,other=0;
        for(auto c:str){
            if(isalpha(c))
                a++;
            else if(c==' ')
                kg++;
            else if(isalnum(c))
                nums++;
            else
                other++;
        }
        cout<<a<<'\n'<<kg<<'\n'<<nums<<'\n'<<other<<endl;
    }
    
    
    return 0;
}


全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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