FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Data-Structure/QuickSort.cpp at master · Cppbocchi/Data-Structure · GitHub
Cppbocchi
/
Data-Structure
Public
forked from
DLily0129/Data-Structure
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Data-Structure
/
QuickSort.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
32 lines (30 loc) · 497 Bytes
Breadcrumbs
Data-Structure
/
QuickSort.cpp
Copy path
File metadata and controls
32 lines (30 loc) · 497 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
include
<
iostream
>
using
namespace
std
;
void
QuickSort
(
int
*arr,
int
low,
int
high)
{
int
i=low,j=high;
int
temp=arr[low];
while
(i<j)
{
for
(;i<j&&arr[j]>=temp;j--);
if
(i<j)
arr[i++]=arr[j];
for
(;i<j&&arr[i]<=temp;i++);
if
(i<j)
arr[j--]=arr[i];
}
arr[i]=temp;
if
(i-
1
>low)
QuickSort
(arr,low,i-
1
);
if
(j+
1
<high)
QuickSort
(arr,j+
1
,high);
}
int
main
()
{
int
a[]={
23
,
31
,
49
,
31
,
6
,
19
};
QuickSort
(a,
0
,
5
);
for
(
int
i=
0
;i<
6
;i++)
cout<<a[i]<<
"
"
;
cout<<endl;
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL