-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquick.txt
77 lines (67 loc) · 1.45 KB
/
quick.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vi vector<int>
#define vll vector<long long>
#define mp make_pair
#define MPII map<int,int>
#define MPLL map<long long,long long>
#define MPSI map<string,int>
#define MPIS map<int,string>
#define PRII pair<int,int>
#define PRLL pair<long long,long long>
#define SP cout<<fixed<<setprecision(10);
#define rep(i,inval,n) for(int i = inval; i < n; i++)
#define all(x) x.begin(),x.end()
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
int Partition(int arr[],int left,int right)
{
int temp,t;
int pivot=arr[right];
int i=left-1;
for(int j=left;j<=right;j++)
{
if(arr[j]<pivot)
{
i++;
temp=arr[j];
arr[j]=arr[i];
arr[i]=temp;
}
}
temp=arr[right];
arr[right]=arr[i+1];
arr[i+1]=temp;
return (i+1);
}
void quick_sort(int arr[],int left,int right)
{
if(left<right)
{
int p=Partition(arr,left,right);
quick_sort(arr,left,p-1);
quick_sort(arr,p+1,right);
}
}
int main()
{
IOS;
int t=1;
// cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
quick_sort(arr,0,n-1);
for(int i=0;i<n;i++) cout<<arr[i]<<" ";
cout<<endl;
}
return 0;
}