package suanfa;import java.util.*;public class test { public void st(String[] s){ String[] e = {}; int n =0; int m =0; System.out.println(Arrays.toString(s)); System.out.println("length"+s.length); for(int i = 0;i<s.length;i++){ for(int j = s.length-1;j>i;j--){ n = i; m =j; System.out.println("i:"+s[i]+"j:"+s[j]); while(s[n]==s[m]){ System.out.println("进入while"); if(n<m-1){ System.out.println("n:"+n+"m"+m); n++; m--; }else{ s=Arrays.copyOfRange(s, i, j+1); System.out.println("结果:"+Arrays.toString(s)); return; } System.out.println("n:"+n+"m:"+m); } } } //System.out.println("结果:"+Arrays.toString(s)); } public String[] shuru(){ Scanner s = new Scanner(System.in); String zu = s.next(); System.out.println("zu:"+zu); String[] shuzu = zu.split(","); System.out.println("输入数组"+Arrays.toString(shuzu)); return shuzu; } public static void main(String[] args) { //String[] shuzu = new String[]{"a","b","c","b","d"}; test t = new test(); String[] shuzu =t.shuru(); t.st(shuzu); }}
添加回答
举报
0/150
提交
取消