#include <stdio.h>
#define TABIN 8 //table increment size
main()
{
int c, nb,nt, pos;
nb = nt = 0; //number of blanks necessary
pos = 1; //position of character in line
for (pos = 1; (c = getchar())!=EOF ; ++pos)
if (c == ' ')
{ if (pos % TABIN != 0)
++nb;
else
{ //when the black reach the defined number
nt++;
nb =0;
}
}
else
{
for (; nt >0; nt--)
putchar('/t');
if (c == '/t')
{
nb = 0;
}
else
for (; nb >0; --nb)
{
putchar(' ');
}
putchar(c);
if (c == '/n')
{
pos = 0;
}
else if (c == '/t')
pos = pos + (TABIN - (pos - 1) % TABIN) -1;
}
}
1-21(和我无关)
最新推荐文章于 2022-02-25 19:38:17 发布