那个求最长上升序列长度的 写了本地过了 还有那个双生字符串,就是求循环字符的匹配 一直卡在数据的格式输入 package zijie; import java.util.ArrayList; import java.util.Scanner; public class Main {     public static void main(String[] args) {         int n;         int t;                           ArrayList<ArrayList<String>> all_str = new ArrayList<ArrayList<String>>();                  Scanner sc1 = new Scanner(System.in);         Scanner sc2 = new Scanner(System.in);         t = sc1.nextInt();          for(int i = 0; i < t; i++) { //            这里想打人             n = Integer.valueOf(sc1.nextLine());             ArrayList<String> one_str = new ArrayList<>();             for(int j = 0; j < n + 1; j++) {                 String str = sc1.nextLine();                 one_str.add(str);             } //            sc1.nextLine();             System.out.println(one_str);             all_str.add(one_str);         }         sc1.close();                  for(int i = 0; i < t; i++) {             ArrayList<String> ar_str = new ArrayList<>();             System.out.println(ar_str);             if(judge(ar_str) == true) {                 System.out.println("Yeah");             }else {                 System.out.println("Sad");             }         }     }     private static boolean judge(ArrayList<String> ar_str) {         int n = ar_str.size();                  for(int i = 0; i < n; i++) {             for(int j = i; j < n; j++) {                 return to_judge(ar_str.get(i), ar_str.get(j));             }         }         return false;     }     private static boolean to_judge(String string, String string2) {         String add_str = string + string;                  System.out.println(add_str );         if(add_str.indexOf(string2) != -1) {             return true;         }                  StringBuffer str_re = new StringBuffer(add_str).reverse();         if(str_re.indexOf(string2) == -1) {             return false;         }else {             return true;         }     } } /*  *   *  3 2 helloworld hdlrowolle 2 helloworld worldhello 2 abcde acbde */
点赞 评论

相关推荐

Noob1024:一笔传三代,人走笔还在
点赞 评论 收藏
分享
牛客网
牛客企业服务