解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s1 = in.next();
String s2 = in.next();
String t;
if (s1.length() < s2.length()) {//这个if作用是s1和s2的值互换;
t = s1;
s1 = s2; //t是空的,先将s1的值给t,这时s1是空的,再把s2的值s1,s2为空,再把t的给s2。完成互换
s2 = t;
}
s1 += s1;
if (s1.indexOf(s2) != -1) {//判断s2是否为双倍s1的子串
System.out.println("true");
} else {
System.out.println("false");
}
}
}
0.0分
1 人评分