There are two strings, named as “str” and “substr”. The number of characters in “str”is less than 10 and the number of characters in “substr” is 3.
The number of characters does not contain the ending ‘\0’.
We will insert “substr” into “str” after the character with the max ASCII code in“str”.
We will insert at the firstmax-ASCII-code character if there are not only one.
Input
The input contains many lines, and each line is a test case in the form of:
str substr
Output
Output the results in each case.
Sample
Inputcopy | Outputcopy |
---|---|
abcab eee 12343 555 |
abceeeab 12345553 |
扫描二维码关注公众号,回复:
14234238 查看本文章
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,in;
int i,pos;
while( cin>>s>>in )
{
pos=0;
for( i=1;i<s.size();i++ )
if( s[pos]<s[i] ) pos=i;
if( pos==s.size()-1 ) s+=in;
else s.insert( pos+1,in );
cout<<s<<endl;
}
return 0;
}