Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void quick(int A[],int n,int beg,int end,int loc)
- {
- int left=beg;
- int right=end;
- loc=beg;
- while(A[loc]<=A[right]&&loc!=right)
- {
- right=right-1;
- }
- if(loc==right)
- return;
- if(A[loc]>a[right])
- {
- int t=a[loc];
- A[loc]=A[right];
- A[right]=t;
- loc=right;
- }
- while(A[left]<=A[loc]&&left!=loc)
- {
- left++;
- }
- if(loc==left)
- return;
- if(A[left]>A[loc])
- {
- temp=A[loc];
- A[loc]=A[left];
- A[left]=temp;
- }
- }
- int main()
- {
- int n,A[100],lower[100],upper[100];
- cin>>n;
- for(int i=0;i<n;i++)
- {
- cin>>A[i];
- }
- int top=0,beg,en,loc,end;
- if(n>1)
- {
- top=top+1;
- lower[top]=1;
- upper[top]=n;
- }
- while(top!=NULL)
- {
- beg=lower[top];
- end=upper[top];
- top=top-1;
- loc=1;
- quick(A,n,beg,end,loc);
- if(beg<loc-1)
- {
- top++;
- lower[top]=beg;
- upper[top]=loc=1;
- }
- if()
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement