#include <iostream>
#include <algorithm>
using namespace std;
int main(){
string str;
while (cin>>str){
string minStr = str;
sort(minStr.begin(), minStr.end());
int i = 0;
while (i<str.size() && str[i]==minStr[i]) i++;
int j = str.size()-1;
while (j>=0 && str[j] != minStr[i]) j--;
swap(str[i],str[j]);
cout<<str<<endl;
}
return 0;
}
一次交换变换最小字符串
最新推荐文章于 2024-11-14 21:19:37 发布