Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define MAXTSPACE 8
- int main()
- {
- int c, temp, spacecnt, charcnt;
- spacecnt = charcnt = MAXTSPACE;
- temp = 0;
- while((c = getchar()) != EOF ) {
- if(c == '\n') {
- putchar(c);
- spacecnt = MAXTSPACE;
- } else if(c == ' ') {
- --spacecnt;
- --charcnt;
- if(spacecnt < 1 && charcnt < 1) {
- printf("\t");
- spacecnt = charcnt = MAXTSPACE;
- }
- } else {
- --charcnt;
- if(charcnt < 1) {
- charcnt = MAXTSPACE;
- }
- putchar(c);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment