#C13928. Condense Whitespace
Condense Whitespace
Condense Whitespace
You are given a string containing multiple words separated by various whitespace characters (including spaces, tabs, and newlines). Your task is to write a program that reduces all consecutive whitespace characters to a single space and removes any leading or trailing whitespace.
Note: You must read the input from standard input and write the output to standard output.
For example, if the input is:
hello world
then the output should be:
hello world
If the input is:
line1\n line2\t\tline3
then the output should be:
line1 line2 line3
inputFormat
The input consists of a single string (which may span multiple lines) that can contain spaces, tabs, and newline characters. The input is provided via standard input.
outputFormat
Output a single line containing the string after condensing all consecutive whitespace characters to one space and removing any leading or trailing whitespace.## sample
hello
hello