7.6 chcount.c -- 使用逻辑与运算符

include <stdio.h>

#define PERIOD '.'
int main(void)
{
    char ch;
    int charcount = 0;
    while ((ch = getchar())  != PERIOD)
    {
        if (ch != '"'  && ch != '\'')
            charcount++;
    }
    printf("There are %d non-quote characters.\n",  charcount);
    return 0;
}
posted on 2019-04-10 21:55  viviLy  阅读(180)  评论(0编辑  收藏  举报