E D R , A S I H C RSS

Fmt

원문보기
----
인기도:C(A,B,C), 성공률:낮음(낮음,보통,높음), 레벨:2(1~4)

About Fmt

fmt라는 유닉스 프로그램은 텍스트를 읽어온 다음 적당히 연결하거나 끊어서 모든 행의 길이가 72글자는 넘지 않지만 최대한 72글자에 가까운 출력 파일을 만들어낸다. 행을 연결하거나 끊을 때는 다음과 같은 규칙을 따른다.
{{|
  1. 입력에 공백이 있으면 어디서든지 새로운 줄을 시작할 수 있다. 새로운 줄이 시작되면 앞 줄의 맨 뒤 및 줄의 맨 앞에 있는 공백은 모두 제거된다.
  2. 입력된 줄바꿈 문자 가운데 (1) 빈 줄 또는 공백만 들어있는 줄 끝에 있는 것과 (2) 그 뒤에 스페이스 또는 다른 줄바꿈 문자가 있는 것을 제외한 모든 줄바꿈 문자는
출력 과정에서 제거될 수 있다. 줄 바꿈 문자가 제거될 때 그 문자는 스페이스로 치환된다.
  1. 출력되는 줄의 맨 뒤에 있는 스페이스는 모두 삭제된다.
  2. 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.

  1. 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.

  1. 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.
|}}

풀이

작성자 사용언어 개발시간 코드
문보창 C++ . Fmt/문보창

쓰레드

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:16
Processing time 0.0123 sec