您的位置:首页 > 编程语言

好久没有写程序,习题5.2。for,getchar等的用法,

2005-04-21 22:39 393 查看
#include <stdio.h>
main()
{
char c;
int n,letter=0,space=0,num=0,other=0;
for (n=0;(c=getchar())!='/n';n++)
  { printf ("%c",c);
    if (c>='a'&&c<='z'||c>='A'&&c<='Z') letter++;
    if (c>='0'&&c<='9') num++;
    if (c==' ') space++;
  }
other=n-letter-num-space;
printf ("n=%d letter=%d num=%d space=%d other=%d",n,letter,num,space,other);
getch();
}
分别统计出,自己输入的字符,有多少个,字母,数字,其他,都是多少。
发现自己在字母上编程有很大问题。
我要努力。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  include c 编程