当前位置:千优问>百科知识>c语言统计字符个数

c语言统计字符个数

2023-05-26 03:07:17 编辑:leo 浏览量:545

c语言统计字符个数

c语言统计字符个数

#include 吵盯#include int main(void){    char input;    int daxie = 0, xiaoxie = 0, kongge = 0, number = 0, others = 0, count = 0;        while((input=getchar()) != '\n')    {        if(input>='a' && input<='z')            xiaoxie++;        else if(input>升埋和='A' && input<='Z')            daxie++;        else if(input == ' ')            kongge++;        else if(input>='0' && input<= '9')            number++;        else         液枝   others++;        count++;    }    printf("大写字母个数为%d,小写字母个数为%d,空格字符个数为%d,数字个数为%d,其他字符个数为%d,总的字符个数为%d\n", daxie, xiaoxie, kongge, number, others, count);    system("pause");    return 0;}

标签:个数,字符,语言