The C Programming Language
題目:
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?
解法:
一開始看不懂題目在寫甚麼……原來只是要我們用C模擬tab的作用方式。
找到tab stop的規則即可輕鬆解決。
tab stop會出現在n + 1的位置。(假設ts = n)
沒有留言:
張貼留言