#K11221. Reverse Digits in a String

    ID: 23421 Type: Default 1000ms 256MiB

Reverse Digits in a String

Reverse Digits in a String

You are given a string that contains both digits and special characters. Your task is to reverse the order of the digits while keeping all non-digit characters in their original positions.

For example, if the input string is "12#34", then the output should be "43#21". Note that the positions of the special characters (like '#' in the example) remain unchanged.

In LaTeX format, the problem can be described as follows: \begin{quote} Given a string ( s ) consisting of digits and other characters, produce a string ( t ) where the digits are reversed in order, but every non-digit character in ( s ) remains in its original position in ( t ). \end{quote}

Input and output are handled via standard input and standard output.

inputFormat

The input consists of a single line containing the string ( s ) (which may be empty). The string can contain any visible ASCII characters.

outputFormat

Output a single line containing the transformed string where the digits have been reversed while non-digit characters remain at their original positions.## sample

12#34
43#21