-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertion.cpp
More file actions
35 lines (26 loc) · 730 Bytes
/
insertion.cpp
File metadata and controls
35 lines (26 loc) · 730 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
#include<bits/stdc++.h>
using namespace std;
/***************************************ORIGINAL aUTHOR*******************************
*************************************************************************************
*************************************************************************************
*************astrainL3gi0N**********************************************************/
int main()
{
int n; cin>>n;
int arr[100];
for(int i = 0; i < n; ++i)
cin>>arr[i];
for(int j = 1; j < n; ++j){
for(int i = j; i > 0; --i){
if(arr[i] < arr[i-1]){
int temp = arr[i];
arr[i] = arr[i-1];
arr[i-1] = temp;
}
else break;
}
}
for(int i = 0; i < n; ++i)
cout<<arr[i]<<' ';
return 0;
}