int [] array = new int []{1,3,-1,5,-2};
int [] newArray = new int []{array.length};
System.out.println("原数组为:");
for (int i = 0; i < array.length; i++) {
System.out.println(array[i]+"");
}
for (int i = array.length-1; i>= 0; i--) {
if (array[i]<0) {
continue;
}
newArray[array.length-i-1] = array[i];
}
System.out.println("倒序后的新数组为:");
for (int i = 0; i < newArray.length; i++) {
System.out.println(newArray[i]+"");
}
阿旭_
Crafon
相关分类