第三次作业

import java.util.Arrays;

public class chaxun {
     public static void main(String[] args) 
    {

            int z[] = { 15,1,2,5,7,15,1,2,5,15,15,1,2,5,30};
            chaxun(z);
                System.out.println(Arrays.toString(z));
       }

    public static void sort(int z[], int xiao, int da) 
    {
            int y, x, index;
            if (xiao > da)
         {
                    return;
                }
            y = xiao;
            x = da;
            index = z[y]; 
            while (y < x) 
        { 
                    while (y < x && z[x] >= index)
                    x--;
                    if (y < x)
                    z[y++] = z[x];
                    while (y < x && z[y] < index)
                    y++;
                    if (y < x) 
                        z[x--] = z[y];
            }
            z[y] = index;
            sort(z, xiao, y - 1); 
               sort(z, y + 1, da); 

        }

    public static void chaxun(int z[]) 
    {
            sort(z, 0, z.length - 1);
        }

   
}

 

posted on 2017-12-03 20:58  爱迪生的  阅读(142)  评论(2)    收藏  举报