荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: alec (AlecMonkeyKing), 信区: ACMICPC
标  题: 发一道在BBS上比较有使用价值的题
发信站: 荔园晨风BBS站 (Sun May 30 09:42:32 2004), 站内信件

Fmt

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


A new line may be started anywhere there is a space in the input. When a
new line is started, blanks at the end of the previous line and at the
beginning of the new line are eliminated.

A line break in the input may be eliminated in the output unless (1) it
is at the end of a blank or empty line, or (2) it is followed by a space
or another line break. When a line break is eliminated, it is replaced
by a space.

Spaces must be removed from the end of each output line.

Any input word containing more than 72 characters must appear on an
output line by itself.

You may assume that the input text does not contain any tabbing
characters.


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.


--
           Computer Science is no more about computers
               than Astronomy is about telescopes.
                                            -- E. W. Dijkstra
Alec

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 210.21.224.236]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店