#288. 字符串最后两字符交换
字符串最后两字符交换
Swap Last Two Characters
Background
None
Problem Description
Given a string of any length, return a new string where the last 2 characters, if present, are swapped. For example, "coding" yields "codign".
Input Format
Input is given from standard input in the following format.
A string.
Output Format
Output is printed to standard output in the following format.
The new string with the last two characters swapped.
Sample
coding
"codign"
cat
"cta"
ab
"ba"
Sample Explanation
For the input "coding\