第三章例3-7

/* 统计字符,包括英文字母、数字字符和其他字符 */
#include<stdio.h>
int main(void)
{
    int digit,letter,other;
    char ch;
    int i;
    digit=letter=other=0;
    printf("Enter 10 characters:");
    for(i=1;i<=10;i++){
        ch=getchar();
        if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
            letter++;
        else if(ch>='0'&&ch<='9')
            digit++;
        else
            other++;
    }
    printf("letter=%d,digit=%d,other=%d
",letter,digit,other);

    return 0;

}

原文地址:https://www.cnblogs.com/laurenliu1994/p/3352030.html