练习1-12:编写一个程序,以每行一个单词的形式打印其输入(C程序设计语言 第2版)
#include <stdio.h> #define NOT_BLANK 1 #define BLANK 0 main() { int c; int last_ch = NOT_BLANK; while ((c=getchar()) != EOF){ if (c == ' ' || c == '\n' || c == '\t'){ if (last_ch == NOT_BLANK) putchar('\n'); last_ch = BLANK;//这条语句可以包括在最近的if里面 }else{ putchar(c); last_ch = NOT_BLANK; } } }