aboutsummaryrefslogtreecommitdiff
path: root/1.21.c
blob: d7f7a270646c832998412f8f123f432b63604ca9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>

#define TAB 8

int 
main(void)
{
  int count, tab, blank;
  char input;

  count = 0;

  while((input = getchar()) != EOF) {
    
    if (input == ' ')
      count++;

    else {

      if (count > 0) {
        for (tab = count/TAB; tab > 0; --tab)
          printf("\t");
        for (blank = count%TAB; blank > 0; --blank)
          printf(" ");
      }
      count = 0;

      printf("%c", input);
    }
  }

  return 0;
}