Discuss / Java / 潜水

潜水

Topic source

黄灏HHz

#1 Created at ... [Delete] [Delete and Lock User]
        // TODO:
        Arrays.sort(ns);
        int maxIndex = (ns.length%2==1)?(ns.length-1)/2:ns.length/2;
        for(int i=0; i<maxIndex; i++) {
            int temp = ns[i];
            ns[i] = ns[ns.length-i-1];
            ns[ns.length-i-1] = temp;
        }

16gXqPH

#2 Created at ... [Delete] [Delete and Lock User]

三目运算那里是不必要的,直接除2就行。


  • 1

Reply