输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。

输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数。

#include<stdio.h>
int main(void)
{
  char ch;
  int i,j,k,l,m;
  i=j=k=l=m=0;
  while((ch=getchar())!='\n')
  {
      if(ch>='a'&&ch<='z')
   j++;
    else if(ch>='0'&&ch<='9')
          k++;
     else if(ch==' ')
          l++;
      else 
          m++;
  }
  printf("%d %d %d %d",j,k,l,m);
  return 0;

}

猜你喜欢

转载自blog.csdn.net/bokaicao/article/details/78070626