/*3.编写一个程序,把输入作为字符流读取,直至遇到 EOF。令其报告输入中的大写字母个数和小写字母个数。假设小写字母的数值是连续的,大写字母也是如此。或者你可以使用 ctypc,h 库中的合适的
函数来区分大小写。*/
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
char a;
int big = 0, small = 0;
printf("Please input string:");
while ((a = getchar()) != EOF)
{
if (isupper(a))
big++;
else if (islower(a))
small++;
}
printf("%dbig and %dsmall\n", big, small);
system("pause");
return 0;
}
C Primer Plus8-3
程序输入字符流统计大写字母与小写字母数量
最新推荐文章于 2024-09-28 21:40:24 发布
本程序通过字符流输入并统计其中的大写字母和小写字母的数量,利用了ctype.h库中的isupper和islower函数进行字母识别。

159

被折叠的 条评论
为什么被折叠?



