考察字符串的输入和处理
#include<stdio.h> int e,s,n,o,i; int main(){ char str[1000]; while(fgets(str,1000,stdin)!=NULL){ e=0,s=0,n=0,o=0; for(int i=0;str[i]!=0;i++){ if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z')){ e++; }else if(str[i]==' '){ s++; }else if(str[i]>='0'&&str[i]<='9'){ n++; }else{ o++; } } printf("%d %d %d %d\n",e,s,n,o-1); } return 0; }