summaryrefslogtreecommitdiffstats
path: root/1/9.c
diff options
context:
space:
mode:
Diffstat (limited to '1/9.c')
-rw-r--r--1/9.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/1/9.c b/1/9.c
new file mode 100644
index 0000000..2fb4866
--- /dev/null
+++ b/1/9.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+
+/* replaces one or more blanks with a single blank */
+int main(int argc, char *argv[]) {
+ int prev, curr;
+
+ prev = 'a';
+
+ while ((curr = getchar()) != EOF) {
+ if (prev == ' ' && curr == ' ') {
+ continue;
+ }
+
+ putchar(curr);
+ prev = curr;
+ }
+
+ return 0;
+} \ No newline at end of file