编程题:输入一行文字,分别统计出其中英文大写字母、小写字母、空格、数字和其它字符的个数。(用指针和

2024-12-19 14:59:20
推荐回答(2个)
回答1:

#include
#include

int main()
{
char c;
int digit = 0, upper = 0, lower = 0, space = 0, other = 0;
while (scanf("%c", &c) == 1 && c != '\n')
{
if (isdigit(c))
++digit;
else if (isupper(c))
++upper;
else if (islower(c))
++lower;
else if (isspace(c))
++space;
else
++other;
}
printf("%d Digit(s), %d Upper Case(s), %d Lower Case(s), %d Space(s), %d Other(s)\n", digit, upper, lower);
}

回答2:

三年前估计我可以帮你,现在姐毕业两年了,这东西早忘光了。多看看课本问题应该不难解决!