插个楼:
#include<stdio.h>
#include<ctype.h>
int main(){
int alpha=0,space=0,digit=0,other=0;
char str[1002];
while(fgets(str,1002,stdin)){
alpha=0,space=0,digit=0,other=0;
for(int i=0;str[i]!='\n';i++){
if(isalpha(str[i]))
alpha++;
else if(str[i]==' ')
space++;
else if(isdigit(str[i]))
digit++;
else
other++;
}
printf("%d\n%d\n%d\n%d\n",alpha,space,digit,other);
}
}