#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();
}
分别统计出,自己输入的字符,有多少个,字母,数字,其他,都是多少。
发现自己在字母上编程有很大问题。
我要努力。