package com.java.test;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
int[] array = new int[]{1,5,6,7,9,2,4};
Test t = new Test();
int i = 0 ;
while (i < array.length - 1) {
t.move(array);
i++ ;
}
}
public static void move(int[] array){
int temp = array[array.length - 1] ;
for (int i = array.length - 1; i > 0; i--) {
array[i] = array[i-1];
}
array[0] = temp ;
System.out.println(Arrays.toString(array));
}
}
用java实现数组的循环逐步移位操作
最新推荐文章于 2023-07-07 14:50:11 发布