第1个回答 2012-11-04
Scanner scan = new Scanner(System.in);
String input = scan.nextLine();
String[] temp = input.split(" ");
int len = 0;
int deleteIndex =0;
try{
len = Integer.parseInt(temp[0]);
deleteIndex = Integer.parseInt(temp[1]);
input = scan.nextLine();
String[] array = input.split(" ");
if(array.length==len){
List<String> list = new ArrayList<String>();
for(int i=0;i<array.length;i++){
if(i!= deleteIndex-1){
list.add(array[i]);
}
}
StringBuffer sb = new StringBuffer();
for(String s:list){
sb.append(s).append(" ");
}
System.out.println(sb.substring(0,sb.length()-1));
}else{
System.out.println("数组长度不一致");
}
}catch(Exception e){
e.printStackTrace();
}本回答被网友采纳