C语言统计单词,空格,符号

#include int main() { int word = 0; int space = 0; int mark = 0; char ch; while ((ch = getchar()) != '\n') { if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') word++; else if (ch == 32) //ch = ' '空格的ASCII码是32 space++; else mark++; } printf("word = %d, space = %d, mark = %d\n", word, space, mark); return 0; }


    推荐阅读