#C12308. Arithmetic Expression Tokenizer
Arithmetic Expression Tokenizer
Arithmetic Expression Tokenizer
You are given a string representing an arithmetic expression. The expression contains multi-digit integers, the four basic arithmetic operators +, -, *, /, and parentheses ( and ). Your task is to tokenize this expression using a regular expression or a custom parsing method.
The tokens should consist of integers or single-character operators/parentheses, and the output should list these tokens in the order they appear in the original expression.
For example, the arithmetic expression
\(3+(6*5-8)/4\)
should be tokenized into:
3, +, (, 6, *, 5, -, 8, ), /, 4
When printing the result, output the tokens joined by a single space.
inputFormat
The input consists of a single line which is a string representing an arithmetic expression. The expression may contain digits, the operators +
, -
, *
, /
, and the parentheses (
and )
. There might be no spaces between characters.
outputFormat
Output the list of tokens extracted from the expression separated by a single space. Each token should be exactly as it appears in the expression (a number, an operator, or a parenthesis).
## sample3+2
3 + 2