import java.util.Scanner;
public class a1 {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
System.out.println("请输入数组的长度");
int length = myScanner.nextInt();
int[] arr1 = new int[length];
int[] arr2 = new int[length];
System.out.println("请输入数组元素的值");
for (int i = 0; i < length; i++) {
arr1[i] = myScanner.nextInt();
}
System.out.print("此时数组为 ");
for (int i = 0; i < length; i++) {
System.out.print(arr1[i] + " ");
}
System.out.println();
int count = 0;
for (int i = length - 1; i >= 0; i--) { //for (int i = length - 1, j = 0; i >= 0; i--, j++) {
arr2[count] = arr1[i]; // arr2[j] = arr1[i];
count++; //}
}
arr1 = arr2;
System.out.print("翻转后的数组为 ");
for (int i = 0; i < length; i++) {
System.out.print(arr1[i] + " ");
}
}
}
04-07
318
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-11
4452
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-20
08-20