第2个回答 2013-02-27
public class ArrayTest01 {
public static void main(String args[]) {
int a[] = new int[10];
int i;
for (i = 0; i < a.length; i++) {
a[i] = i;
}
for (int n : a) {
System.out.print(n + " ");
}
int temp;
for (i = 0; i < (a.length) / 2; i++) {
temp = a[i];
a[i] = a[a.length - 1 - i];
a[a.length - 1 - i] = temp;
}
System.out.println("\n数组倒置:");
for (int n : a) {
System.out.print(n + " ");
}
}
}本回答被网友采纳