#PCBTAM0000023. Gọt khoảng trắng hai đầu (Trim Outer Whitespace)
Gọt khoảng trắng hai đầu (Trim Outer Whitespace)
Trim Outer Whitespace
Version: Phuoc Hung OJ Extended
Problem Statement
Given one text line , remove all consecutive ASCII spaces (U+0020) and horizontal tabs (U+0009) from the beginning and end of the string. Preserve every character between the first and last non-whitespace characters, including internal spaces and tabs.
Report the length before trimming, the length after trimming, and the resulting string enclosed in | characters so an empty result is visible.
Input
One line contains , which may be empty or consist entirely of spaces and tabs. The line terminator is not part of .
Output
Print three lines: the original length; the trimmed length; and the trimmed string enclosed by | characters.
Subtasks
- Subtask 1 (100 points): ; each character is printable ASCII or a U+0009 tab.
Examples
Example 1
Input
A B
Output
7
3
|A B|
Explanation. A B has length ; trimming two spaces from each end leaves A B of length .
Example 2
Input
X
Output
4
1
|X|
Explanation. The tab-space-X-tab input has length ; trim the three outer whitespace characters to get X.
Example 3
Input
Output
3
0
||
Explanation. All three spaces are removed; the empty result has length and is displayed as ||.