K& R练习1-20-需要澄清 [英] K&R Exercise 1-20 - Need some clarification

查看:81
本文介绍了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)

这篇关于K& R练习1-20-需要澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆