为了账号安全,请及时绑定邮箱和手机立即绑定

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

/ 猿问

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

枫夜流萤 2019-05-03 18:29:42

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
提交
取消
意见反馈 帮助中心 APP下载
官方微信