AcWing 773. 字符串插入 - Java
原题链接
中等
作者:
KYCygni
,
2021-03-17 03:22:10
,
所有人可见
,
阅读 355
Java 代码
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
while (cin.hasNextLine())
{
StringTokenizer tokens = new StringTokenizer(cin.nextLine());
String s = tokens.nextToken();
String sub = tokens.nextToken();
int p = 0;
for (int i = 0; i <s.length(); i ++)
{
if (s.charAt(i) > s.charAt(p))
p = i;
}
System.out.println (s.substring(0, p+1) + sub + s.substring(p+1));
}
}
}