1 #include <stdio.h> 2 #define TABINC 8 3 4 main() 5 { 6 int c, nb, nt, pos; 7 nb = 0; 8 nt = 0; 9 for(pos = 1; (c = getchar()) != EOF; ++pos) 10 if(c == ' ') 11 { 12 if(pos % TABINC != 0) 13 ++nb; 14 else 15 { 16 nb = 0; 17 ++nt; 18 } 19 } 20 else 21 { 22 for( ; nt > 0; --nt) 23 putchar('\t'); 24 if(c == '\t') 25 nb = 0; 26 else 27 for( ; nb > 0; --nb) 28 putchar(' '); 29 putchar(c); 30 if(c == '\n') 31 pos = 0; 32 else if (c == '\t') 33 pos = pos + (TABINC - (pos - 1) % TABINC) - 1; 34 } 35 }