题解 | #统计大写字母个数#
统计大写字母个数
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")
查看5道真题和解析
