#include<stdio.h>
#include<ctype.h>
int main()
{
char str[80];
int i;
int digit=0,lower=0,upper=0,space=0,other=0;
printf("请输入一行字符串: \n");
fgets(str,sizeof(str),stdin);
i=0;
while(str[i]!='\0' && str[i]!='\n')
{
if(isdigit(str[i]))
digit++;
else if(islower(str[i]))
lower++;
else if(isupper(str[i]))
upper++;
else if(isspace(str[i]))
space++;
else
other++;
i++;
}
printf("digit characters: %d\n",digit);
printf("lower case letters:%d\n",lower);
printf("upper case letters:%d\n",upper);
printf("space :%d\n",space);
printf("others:%d\n",other);
return 0;
}
统计字符串中数字,小写字母,大写字母,空白字符和其他字符的个数
141 浏览量
2024-03-24
11:27:25
上传
评论
收藏 42KB ZIP 举报
猿来不是你
- 粉丝: 6
- 资源: 40