本文最后更新于 2181 天前,其中的信息可能已经有所发展或是发生改变。
#include<stdio.h>
#include <string>
using namespace std;
int main()
{
int a=0,b=0,c=0,d=0;
char ch;
printf("请输入字符串\n");
while((ch=getchar())!='\n')
{
if(ch>='0'&&ch<+'9')
a++;
else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
b++;
else if(ch==' ')
c++;
else
d++;
}
printf("有 %d个数字 %d个英文字母 %d个空格 %d个其他字符",a,b,c,d);
return 0;
}