输入三行字符,每行40个字符,要求统计出其*有多少大写字母、小写字母、空格和其他字符。

#include <stdio.h>
#include <string.h>
const int N=80;
int main()
{
    char str[N];
    int  len, i, letter = 0, digit = 0, space = 0, others = 0, j;
    for(j=0;j<3;++j)
{
    gets(str);
    len = strlen(str);
    for (i=0; i<len; i++)
    {
      if (('a' <= str[i] && str[i] <= 'z') || ('A' <= str[i] && str[i] <= 'Z'))
              letter ++;
         else if ('0' <= str[i] && str[i] <= '9')
                 digit ++;
         else if (str[i] == ' ' )
                 space ++;
         else
        others ++;
       }
    printf("English character:  %d\n", letter);
  	printf("space:  %d\n", space);
    printf("other character:  %d\n", others+digit);
}
return 0;
}




上一篇:telnet 命令方式体验HTTP请求


下一篇:ngrok