作者在 2011-05-15 22:58:39 发布以下内容
#include<stdio.h>
main()
{
int letters=0,numbers=0,space=0,others=0; /*先把字母,数字,空格,其他设为零*/
char ch;
printf("please input some characters\n");
while((ch=getchar())!='\n')
{
if(ch>='a'&&ch<='z'||ch>='A'&&ch<='Z')
letters++;
else if(ch>='0'&&ch<='9')
numbers++;
else if(ch==' ')
space++;
else
others++;
}
printf("char=%d number=%d space=%d others=%d\n",letters,numbers,space,others);
}
应该看得懂吧,不加注释了,本来准备再写几个代码的,没想到打字太慢,时间太晚,明天再写吧,玩一盘dota