C

/* Write a program that prints its input one word per line. */

#include <stdio.h>

#define IN  1  /* inside a word  */
#define OUT 0  /* outside a word */

/* print input one word per line */
main()
{
	int c, state = OUT;
	while((c = getchar()) != EOF)
	{
		if(c == ' ' || c == '
' || c == '	')
		{
			if(state == IN)
			{
				putchar('
');  /* finish the word */
				state = OUT;
			}
			else if(state == OUT)
			{
				state = IN;  /* beginning of word */
				putchar(c);
			}
			else  /* inside a word */
			{
				putchar(c);
			}
		}
	}
}
原文地址:https://www.cnblogs.com/zhchoutai/p/6991302.html