第1个回答 推荐于2016-08-19
public class test_2 {
public static void main(String[] args) {
int[] a = new int[10];
for (int i = 0; i < 10; i++) {
a[i] = (int) (Math.random() * 31) + 20;
System.out.print(a[i] + " ");
}
yiwei(a);
System.out.println();
for (int i = 0; i < 10; i++) {
System.out.print(a[i] + " ");
}
}
private static void yiwei(int a[]) {
int length = a.length - 1;
int first = a[0];
for (int i = 0; i < length; i++) {
a[i] = a[i + 1];
}
a[length] = first;
}
}本回答被提问者采纳