键盘输入和直接写相同的数组但是结果不同

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);

}


}


枫夜流萤
浏览 731回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java