- Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathQuickSort.cpp
More file actions
Latest commit
59 lines (56 loc) · 892 Bytes
/
Copy pathQuickSort.cpp
File metadata and controls
59 lines (56 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
usingnamespacestd;
#defineLLlonglong
#definemp make_pair
#definepb push_back
#definemt make_tuple
#defineLDlongdouble
#definegc getchar_unlocked
#definepc putchar_unlocked
#defineMOD1000000007
#defineMAXN100005
#definebitcount _builtin_popcount
#defineINF2000000000
#defineEPS1e-9
template<typename T>T absll(T X)
{
if(X<0)
return -1*X;
else
return X;
}
intPartition(int A[],int low,int high)
{
int x=A[high];
int i=low-1;
int j;
for(j=low;j<high;j++)
{
if(A[j]<=x)
{
swap(A[i],A[j]);
++i;
}
}
swap(A[i+1],A[high]);
return i+1;
}
voidQuickSort(int A[],int low,int high)
{
if(low<high)
{
int p=Partition(A,low,high);
QuickSort(A,low,p-1);
QuickSort(A,p+1,high);
}
}
int A[10]={8,7,6,5,4,3,2,1,0};
intmain()
{
QuickSort(A,0,8);
for(int i=0;i<9;i++)
{
cout<<A[i]<<"";
}
return0;
}