2014年西北工业大学机试第八题
程序员文章站
2022-05-15 14:02:22
...
#include<iostream>
#include<string>
using namespace std;
int main(){
int a = 0,b = 0,c = 0,d = 0;
string s;
getline(cin,s);
for(int i = 0;i < s.length();i++){
if( (s[i] >= 'a'&&s[i] <= 'z')||(s[i] >= 'A'&&s[i] <= 'Z') ){
a ++;
}else if(s[i] == ' '){
b ++;
}else if(s[i] >= '0'&&s[i] <= '9'){
c ++;
}else{
d++;
}
}
cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
return 0;
}