import java.util.Scanner;
public class Reverse {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int arr[] = new int[5];
System.out.println("Enter the values in the array");
for (int i = 0; i < arr.length - 1; i++) {
arr[i] = sc.nextInt();
}
for (int i = 0; i < 5; i++) {
int temp;
int j = 4;
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
j--;
System.out.println(arr[i]);
}
}
}
这个逻辑没有对整数数组进行反转,为什么????
输入 123
输出为 0123
i < arr.length/2
是在做什么?:-)
- Tim Biegeleisen