diff --git a/The C Programming Language/1.12.c b/The C Programming Language/1.12.c new file mode 100644 index 0000000..9d63cbb --- /dev/null +++ b/The C Programming Language/1.12.c @@ -0,0 +1,35 @@ +#include + +#define IN 1 +#define OUT 0 + +main() +{ + int c, state, word_ending; + state = 0; + while ((c = getchar()) != EOF) + { + word_ending = (c == ' ' || c == '\n' || c == '\t'); + if (state == IN) + { + if (word_ending) + { + state = OUT; + putchar('\n'); + } + else + { + putchar(c); + } + } + else + { + if (!word_ending) + { + state = IN; + putchar(c); + } + } + } +} +