作业3(3)输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数

#include<stdio.h>
int main(void)
{
    int yinwen,shuzi,koge,other;
    char ch;
    int i;
    yinwen=shuzi=koge=other=0;
    printf("Enter 15 characters:");
    for(i=1;i<=15;i++){
        ch=getchar( );
            if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
                yinwen++;
            else if(ch>='0'&&ch<='9')
                shuzi++;
            else if(ch>=' '&&ch<='
')
                koge++;
            else
                other++;
    }
    printf("yinwen=%d,shuzi=%d,koge=%d,other=%d
",yinwen,shuzi,koge,other);

    return 0;

}

原文地址:https://www.cnblogs.com/blgl/p/3374968.html