题解 | #统计大写字母个数#

统计大写字母个数

https://www.nowcoder.com/practice/434414efe5ea48e5b06ebf2b35434a9c

  • 再来个C++版本
#include <iostream>
#include <string>
using namespace std;

int main() {
    int cnt = 0;
    string s;
    while (getline(cin, s)) { // 注意 while 处理多个 case
        for (char ch : s) {
            if (isupper(ch)) {
                cnt ++;
            }
        }
        cout << cnt << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

迷茫的大四🐶:价格这么低都能满了?
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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