
代码如下:
#include <stdio.h>
int main()
{
char buf[40]={0};
int i = 0;
int A=0,a=0,nmb =0,other=0;
printf("请输入英文标题:");
gets(buf);
while(buf[i] != '\0')
{
if(buf[i]>='a' && buf[i]<='z')
a++;
else if(buf[i]>='A' && buf[i]<='Z')
A++;
else if(buf[i]>='0' && buf[i]<='9')
nmb++;
else
other++;
}
printf("大写字母%d个,小写字母%d个,数字%d个,其它字符%d个\n",A,a,nmb,other);
return 0;
}