#P1553. Digit Reversal
Digit Reversal
Digit Reversal
Given a number, reverse its digits in a special manner depending on its format. The number may be an integer, a decimal, a fraction, or a percentage.
- Integer: Reverse all digits. For example, 12345 becomes 54321.
- Decimal: Reverse the integer part and the fractional part separately without swapping their positions. For example, 123.456 becomes 321.654.
- Fraction: Given in the format a/b, reverse the digits of the numerator and the denominator separately. Do not swap their positions. For example, 12/34 becomes 21/43.
- Percentage: The number (without the percentage sign) is always an integer. Only the digits are reversed while keeping the '%' sign at the end. For example, 25% becomes 52%.
Your task is to output the transformed number according to the rules above.
inputFormat
The input consists of a single line containing the number in one of the four formats: integer, decimal, fraction, or percentage.
outputFormat
Output the transformed number after reversing its digits according to the given rules.
sample
12345
54321