原题在哪,没地方测试通过率啊😥 import java.util.Scanner; public class shiyan { public static void main(String[] args) { Scanner in = new Scanner(System.in); while (in.hasNext()) { String s1 = in.nextLine(); String s2 = in.nextLine(); int max = -1; for(int i = 0;i<s2.length();i++) { if(s1.charAt(0) == s2.charAt(i) &;&; method(s1,1,s2,i+1) &;&; i>max){ max = i; } } System.out.println(max); } } //对于满足第一个字符相同的索引进行判断 public static boolean method(String s1,int index1,String s2,int index2){ if(index1 == s1.length()){ return true; } if(index2 == s2.length()){ return false; } if(s1.charAt(index1) == s2.charAt(index2)){ return method(s1,index1+1,s2,index2+1); } else{ return method(s1,index1,s2,index2+1); } } }

相关推荐

迷茫的大四🐶:都收获五个了,兄弟那还说啥,不用改了,去玩吧
点赞 评论 收藏
分享
10-29 15:51
嘉应学院 Java
后端转测开第一人:你把简历的学历改成北京交通大学 去海投1000份发现基本还是没面试
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务