#include int main(int argc, const char * argv[]) { char input[9]; int number[9], digit, max, pos1, pos2, result; scanf("%s", input); for (digit = 0; input[digit] != '\0'; digit++) number[digit] = (int)(input[digit] - '0'); for (pos1 = max = digit = 0; input[digit] != '\0'; digit++) if (number[digit] >= max) { max = number[digit]; pos1 = digit; } for (pos2 = 0; number[pos2] >= max; pos2++); result = number[pos2]; number[pos2] = number[pos1]; number[pos1] = result; for (result = digit = 0; input[digit] != '\0'; digit++) result = result * 10 + number[digit]; printf("%d\n", result); return 0; }