day11

作者: 今生何求惟你 | 来源:发表于2018-06-21 23:54 被阅读10次

    题目:输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。

    #include <stdio.h>

    main()

    {

    int a,b,c,d;

    char s;

    a = 0;b = 0;c = 0;d = 0;

    printf("Please input some characters :");

    while( (s = getchar())!= '\n')

    {

    if((s >= 'a' && s <= 'z')||(s >= 'A' && s <= 'Z'))

    a++;

    else if(s >= '0' && s <= '9')

    b++;

    else if( s = ' ' )

    c++;

    else

    d++;

    }

    printf("all in all:char=%d space=%d digit=%d others=%d\n",a,c,b,d);

    return 0;

    }

    相关文章

      网友评论

        本文标题:day11

        本文链接:https://www.haomeiwen.com/subject/qepfyftx.html