K& R练习1-20-需要澄清

问题描述:

我不完全理解以下练习要问的内容:

I don't fully understand what the following exercise is asking:

编写一个程序detab,用适当数量的空格替换输入中的制表符,以留出下一个制表位.假定一组固定的制表位,例如每n列.是变量还是符号参数?"

"Write a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a variable or a symbolic parameter?"

有人可以澄清粗体部分吗?

Could someone clarify the bolded part?

此练习要求您通过添加正确数量的空格来模拟制表符的行为,以使输出仍在制表符停止位置对齐.

This exercise is asking you to emulate the behavior of tabs by adding the correct amount of spaces, such that the output is still aligned on tab stops.

例如:

"hello\tworld"

应成为:

"hello   world"

(制表符已被替换为三个空格),如果制表符停靠点是每4列(即n = 4).

(the tab has been replaced with three spaces), if tab stops are every 4 columns (ie. n = 4).

或者通过指出制表符的停止位置来澄清:

Or to clarify by indicating where the tab stops are :

hello   world
^   ^   ^   ^

如果制表位是每3列,那么您应该获得:

If tab stops are every 3 columns, then you should get :

hello world
^  ^  ^  ^

(该标签仅被1个空格取代了)

(the tab was replaced by only 1 space)