作业3-3

//输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
#include<stdio.h>
int main(void)
{
    int digit,space,enter,letter,other;
    char ch;
    int i;
    digit=space=enter=letter=other=0;
    printf("Enter 15 characters:");
    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=' ')
            space++;
        else if(ch='   ')
            enter++;
        else
            other++;
    }
    printf("letter=%d,space=%d,enter=%d,digit=%d,other=%d
",letter,space,enter,digit,other);

    return 0;
}

空格是搞出来了,但是回车还是不知道要怎么用,求老师上课时教一下

原文地址:https://www.cnblogs.com/lxhlxx900126/p/3379021.html