题解 | #统计字符#
统计字符
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;
}