AcWing 776. 字符串移位包含问题 - Java
原题链接
困难
作者:
KYCygni
,
2021-03-18 05:59:32
,
所有人可见
,
阅读 463
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
String s1 = cin.next();
String s2 = cin.next();
if (s1.length() < s2.length())
{
String temp = s1;
s1 = s2;
s2 = s1;
}
boolean found = false;
for (int i = 0; i < s1.length(); i ++)
{
String n = s1.substring (i) + s1.substring (0, i);
if (n.indexOf(s2) != -1)
{
found = true;
System.out.println ("true");
break;
}
}
if (! found)
System.out.println ("false");
}
}
不是哥们 你这题解不能AC阿