-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbubble.txt
62 lines (54 loc) · 1.21 KB
/
bubble.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
#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;
void bubble_sort(int arr[],int n)
{
int temp;
for(int i=0;i<n;i++)
{
for(int j=0;j<n-i-1;j++)
{
if(arr[j]>arr[j+1])
{
temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}
}
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];
bubble_sort(arr,n);
for(int i=0;i<n;i++) cout<<arr[i]<<" ";
cout<<endl;
}
return 0;
}