统计英文字母、空格、数字和其它字符的数目

#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>

int main()
{
char c;
int zimu=0;
int kongge=0;
int shuzi=0;
int other=0;

printf("请输入字符:");
while ((c = getchar())!= '\n')
{
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
{
zimu++; continue;
}
if (c == ' ')
{
kongge++; continue;
}
if (c > '0' && c < '9')
{
shuzi++; continue;
}
other++;
}
printf("%d %d %d %d", zimu, kongge, shuzi, other);
return 0;
}

 

posted @ 2022-03-23 13:52  小白露  阅读(137)  评论(0)    收藏  举报