• 个人简介

    电子邮箱:syc20110224@outlook.com 最爱快速排序

    #include <cstdio>
    using namespace std;
    int n,book[100005];
    void quicksort(int l,int r)
    {
        int i,j,t,temp;
        if(l>r)
            return;
        temp=book[l];
        i=l;
        j=r;
        while (i!=j)
        {
            while (book[j]>=temp && i<j)
            {
                j--;
            }
            while (book[i]<=temp && i<j)
               i++;
            if(i<j)
            {
                t=book[i];
                book[i]=book[j];
                book[j]=t;
            }
        }
        book[l]=book[i];
        book[i]=temp;
    
        quicksort(l,i-1);
        quicksort(i+1,r);
        return;
    }
    int main()
    {
        int i,j;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
           scanf("%d",&book[i]);
        quicksort(1,n);
        for(i=1;i<=n;i++)
            printf("%d ",book[i]);
        return 0;
    }
    
    
  • 通过的题目

  • 最近活动

    This person is lazy and didn't join any contests or homework.
  • 最近编写的题解

    This person is lazy and didn't write any solutions.