## 2013年7月30日 星期二

### 848 - Fmt

在 unix 系統中，有一個 fmt  程式，用來處理文字顯示，結合許多行，或者是將行與行之間分行，而且每一行最多 72 個字元(含)，處理結合行與分行的規則如下：

• 對於一個新段落，一開始可能會有許多空白，而段落最後不會存在多餘的空白。

• 分行字元 '\n' 將不會在輸入時顯示，而在輸出部分，段落可能占有數行，其中的每一行尾端不會存在空白。在段落結束前，每一行一開始將不會有任何空白或者空行。如果輸入的 '\n' 字元被結合成一行時，則替換成一個空白進行串接。
• 每的字詞不超過 72 個字元，也就是再長的字元最多占有一行。
• 每個字詞不允許跨行，一定要在同一行顯示。

## Sample Input

   Unix fmt

The unix fmt program reads lines of text, combining
and breaking lines so as to create an
output file with lines as close to without exceeding
72 characters long as possible.  The rules for combining and breaking
lines are as follows.

1.  A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the
end of the previous line or at the beginning of the new line.

2.  A line break in the input may be eliminated in the output, provided
it is not followed by a space or another line break.  If a line
break is eliminated, it is replaced by a space.


## Sample Output

   Unix fmt

The unix fmt program reads lines of text, combining and breaking lines
so as to create an output file with lines as close to without exceeding
72 characters long as possible.  The rules for combining and breaking
lines are as follows.

1.  A new line may be started anywhere there is a space in the input.
If a new line is started, there will be no trailing blanks at the end of
the previous line or at the beginning of the new line.

2.  A line break in the input may be eliminated in the output,
provided it is not followed by a space or another line break.  If a line
break is eliminated, it is replaced by a space.


Miguel Revilla 2002-06-15