fork download
  1. #include<stdio.h>
  2. #define TABINC 8
  3.  
  4. int main(void)
  5. {
  6. int nb,nt,pos,c;
  7.  
  8. nb = 0;
  9. nt = 0;
  10.  
  11. for(pos=1;(c=getchar())!=EOF;++pos)
  12. if( c == ' ')
  13. {
  14. if((pos % TABINC) != 0)
  15. ++nb;
  16. else
  17. {
  18. nb = 0;
  19. ++nt;
  20. }
  21. }
  22. else
  23. {
  24. for( ; nt > 0 ; --nt)
  25. putchar('\t');
  26. if( c == '\t')
  27. nb = 0;
  28. else
  29. for( ; nb > 0; --nb)
  30. putchar(' ');
  31.  
  32. putchar(c);
  33.  
  34. if(c == '\n')
  35. pos = 0;
  36. else if ( c == '\t')
  37. pos = pos + ( TABINC - (pos -1) % TABINC) - 1;
  38. }
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
Standard output is empty