#include<iostream>
using namespace std;
int main(){
string line;
int i,len;
int space=0,number=0,character=0,other=0;
getline(cin,line);
len=line.length();
for(i=0;i<len;i++){
if(line[i]==' '){ //字符ch为空' '
space++;
}
else if(line[i]>='0'&&line[i]<='9'){ //字符为数字0~9
number++;
}
else if(line[i]>='a'&&line[i]<='z'||line[i]>='A'&&line[i]<='Z'){ //字符为字母a~z,A~Z
character++;
}
else{
other++;
}
}
cout<<character<<number<<space<<other;
return 0;
}
c语言: