Discuss / Java / 先正序排,然后交换位置

先正序排,然后交换位置

Topic source

细雨小巷

#1 Created at ... [Delete] [Delete and Lock User]
Arrays.sort(ns);
        for(int i = 0; i < ns.length -1; i++) {
           int j = ns.length - i - 1;
           if(i < j) {
               int t = ns[j];
               ns[j] = ns[i];
               ns[i] = t;
           }
        }

  • 1

Reply