题解 | #统计字符#
统计字符
https://www.nowcoder.com/practice/539054b4c33b4776bc350155f7abd8f5
#include <iostream>
using namespace std;
int main() {
string str;
getline(cin, str);
// a英文字母,b空格,c数字,d其他
int a = 0, b = 0, c = 0, d = 0;
for (char ch:str){
if (isalpha(ch)){
++a;
}else{
if (ch == ' '){
++b;
}else{
if (isdigit(ch)){
++c;
}else{
++d;
}
}
}
}
cout << a << endl << b << endl << c << endl << d << endl;
}
#23届找工作求助阵地##我的实习求职记录##14天打卡计划##春招##零基础学习C++#


查看23道真题和解析