8.11.3 统计大小写字符个数

Posted eisnull

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了8.11.3 统计大小写字符个数相关的知识,希望对你有一定的参考价值。

技术图片

# 8.11.3.c
#include <stdio.h>
#include <ctype.h>
int main(void)
{
    char ch;
    int upper = 0, lower = 0, total = 0;

    while ((ch = getchar()) != EOF)
    {
        ++total;
        if (islower(ch) > 0)
            ++lower;
        else if (isupper(ch) > 0)
            ++upper;
    }

    printf("大写字母%d个,小写字母%d个,共%d个字符\\n", upper, lower, total);
    return 0;
}

技术图片

以上是关于8.11.3 统计大小写字符个数的主要内容,如果未能解决你的问题,请参考以下文章