输入一行字符,分别统计出其中字母、空格、数字和其他字符的个数。
#include <iostream>
using namespace std;
int main(void)
{
char ch;
int digit, letter, space, other;
digit = letter = space = other = 0;
while ((ch=getchar())!='\n')
{
if (ch >= 'a'&&ch <= 'z' || ch >= 'A'&&ch <= 'Z')//注意不能写做a<ch<z
letter++;
else if (ch >= '0' && ch <= '9')
digit++;