Topics requirements: You can not use the new array will be reversed only with the original array

cn.itcast.day05.demo03 Package ; 

/ **
* @author newcityman
* @date 2019/7/4 - 0:36
* Topics requirements: not use the new array, it is inverted by the original unique array
* Analysis 1 , switching positions symmetrical
* 2, two position index
* 3, two numbers to be exchanged, it needs third number
* /
public class Demo07Reverse {
public static void main (String [] args) {
int [] Array = { 15 , 52 is , 24 , 36 , . 9 , . 6 , 87} ;
for ( int I = 0 ; I <Array. length ; I ++) {
. the System Out.print (Array [I] +" ");
}
System.out.println();
System.out.println("++++++++++++++++++++++++++++");
int temp;
for (int min = 0,max=array.length-1; min <= max; min++,max--) {
temp = array[min];
array[min] =array[max];
array[max] =temp;
}
for (int i = 0; i < array.length; i++) {
System.out.print(array[i]+",");
}
}
}

Guess you like

Origin www.cnblogs.com/newcityboy/p/11130020.html