给定⼀个数组,把这个数组中所有元素顺序进⾏颠倒

    技术2022-07-14  77

    public class Test15 { public static void main(String[] args) { int[] a = {1,3,5,4}; int temp = 0; for(int i = a.length - 1; i > a.length / 2; i--) { temp = a[i]; a[i] = a[a.length - 1 - i]; a[a.length - 1 - i] = temp; } for(int i = 0; i < a.length; i++) { System.out.println(a[i]); } } } //输出:4 3 5 1
    Processed: 0.009, SQL: 10