编写一个程序,以每行一个单词的形式打印输入.
- #include <stdio.h>
- #define OUT 0
- #define IN 1
- int main(void)
- {
- int c, state;
- state = OUT;
- while((c = getchar()) != EOF)
- {
- if(c == ' ' || c == '\t' || c == '\n')
- {
- if(state == IN)
- putchar('\n');
- state = OUT;
- }
- else
- {
- putchar(c);
- if(state == OUT)
- state = IN;
- }
- }
- return 0;
- }