反向查找 不插入直接输出
C++ 代码
#include <iostream>
#include <string>
using namespace std;
int main(){
string a, b;
while(cin >> a >> b){
int max_i = a.size() - 1;
for(int i = a.size() - 1; i >= 0; --i){
if(a[i] >= a[max_i]) max_i = i;
}
for(int i = 0; i <= max_i; ++i) cout << a[i];
cout << b;
for(int i = max_i+1; i < a.size(); ++i) cout << a[i];
puts("");
}
return 0;
}