#include<stdio.h>
int main(){
char a[1000];
int b=0,c=0,d=0,e=0,f=0,i;
printf("请输入一串字符:");
gets(a);
for(i=0;a[i]!='\0';i++)
if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z')
b++;
else if(a[i]>='0'&&a[i]<='9')
c++;
else if(a[i]==' ')
e++;
else
f++;
printf("英文字符为%d个\n",b);
printf("数字字符为%d个\n",c);
printf("空格为%d个\n",e);
printf("其他字符为%d个\n",f);
return 0;
}
输入一串字符 输出其中英文字母、数字、空格及其他字符的个数
最新推荐文章于 2024-07-18 16:22:57 发布