作业三-3应用分支与循环结构解决问题——统计字符

#include<stdio.h>
int main(void)
{
    int blank,digit,other,letter;
    char ch;
    int i;
    blank=digit=other=letter=0;
    printf("Enter 15 个字符:");
    for(i=1;i<=15;i++){
    ch=getchar( );
    if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z'))
        letter++;
    else if(ch>='0'&&ch<='9')
        digit++;
    else if(ch>=' '&&ch<=' ')
        blank++;
    else
        other++;
    }

printf("blank=%d,digit=%d,letter=%d,other=%d
",blank,digit,letter,other);
return 0;
}
原文地址:https://www.cnblogs.com/2013djj/p/3391776.html