62,628
社区成员
发帖
与我相关
我的任务
分享public static void main(String[] args) {
String str1 = "bvsfsd01u";
String str2 = "yysd0x";
// 找出str1与str2较长的赋值到strLonger,较短的复制到strShorter
String strLonger, strShorter;
if (str1.length() > str2.length()) {
strLonger = str1;
strShorter = str2;
} else {
strLonger = str2;
strShorter = str1;
}
for (int i = strShorter.length(); i > 0; i--) {
for (int j = 0; j < strShorter.length() - i; j++) {
String subStr = strShorter.substring(j, j + i); //截取strShorter的子串
if (strLonger.contains(subStr)) { //判断子串是否在strLonger中
//输出最长子串
System.out.println(subStr);
return;
}
}
}
System.out.println("无子串");
}
第二题的话,就是取这条线上的点然后把圆的圆心设置到这些点上,这个圆就顺着这条线移动了。