#T685. 数字变位
数字变位
Description
Xiao Ming has a number x, and now he wants to rearrange its digits to obtain the largest possible number and the smallest possible number. Can you help him? Note: Xiao Ming does not want the highest digit of the number to be 0.
Input Format
Input a number x;
Output Format
Output two numbers, representing the rearranged largest number and smallest number, separated by a space;
【Data Range】
For 25% of the data, 1 ≤ x < 10000;
For 100% of the data, 1 ≤ x < 10^9;
【Sample Explanation】
For example, 9037 contains "9", "0", "3", "7"; the largest number that can be formed is 9730;
Since "0" cannot be in the thousands place, the smallest number that can be formed is 3079.
Source
CodesOnline