题解 | #字符统计#

金字塔

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

using namespace std;
#define int long long
#define endl '\n'
signed main(){
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   char s;
    int letter=0,digits=0,other=0;
    while(cin.get(s)&&s!='?'){//用cin.get是处理空格也是一个字符,用cin不能算空格是字符。如果用s=getchar()会运行超时,不过把getchar写在循环下面就不会超时了    
        if((s>='a'&&s<='z')||(s>='A'&&s<='Z'))letter++;
        else if(s>='0'&&s<='9')digits++;
        else other++;
    }
    cout<<"Letters="<<letter<<endl;
    cout<<"Digits="<<digits<<endl;
    cout<<"Others="<<other<<endl;
    return 0;
}
全部评论

相关推荐

2025-11-15 14:35
南京邮电大学 Java
程序员牛肉:你这简历有啥值得拷打的?在牛客你这种简历一抓一大把,也就是个人信息不一样而已。 关键要去找亮点,亮点啊,整个简历都跟流水线生产出来的一样。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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