public static void main(String[] args) {
int[] arr = {120, 119, 110, 528, 520};
for (int i = 0; i < arr.length / 2; i++) {
int left = i;
int right = arr.length - i - 1;
int tmp = arr[left];
arr[left] = arr[right];
arr[right] = tmp;
}
for (int i = 0; i < arr.length; i++) {
System.out.println(arr[i]);
}
}
数组反转——java
最新推荐文章于 2024-08-23 21:37:43 发布