#include #include #include #include int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); char tmp; std::vector input; while (std::cin >> tmp) { input.push_back(tmp-'0'); } std::vector max_checker(input); std::sort(max_checker.begin(), max_checker.end()); std::reverse(max_checker.begin(), max_checker.end()); for (std::vector::reverse_iterator it = input.rbegin(); it != input.rend(); ++it) { if (*it == max_checker[0]) { for (std::vector::iterator it2 = input.begin(); it2 != input.end(); ++it2) { if (*it2 != max_checker[0]) { std::swap(*it, *it2); goto OUTPUT; } } } } OUTPUT: for (auto it : input) { std::cout << it; } std::cout << "\n"; return 0; }