← 返回 microsoft 的题目列表Split String by Spaces Unless '*' Appears
类型:online_judge
Problem: Split String by Spaces Unless '*' Appears
Given a string s, split it into tokens using the following rules:
If s does not contain '*':
split by one or more spaces
ignore empty tokens produced by multiple spaces
If s does contain '*':
split by the '*' character
keep the content on both sides as-is (including spaces)
ignore empty tokens produced by consecutive '*'
Return the list of tokens.
Input (stdin)
One line string s (may include spaces and *).
Output (stdout)
Print m then m lines, each a token.
Constraints
1 <= len(s) <= 2e5
Examples
Same as the Chinese version.
Example
Input
a bc d
Output
3
a
bc
d