Last active
May 5, 2020 14:02
-
-
Save sandes/77aec1aec65a8397778c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
void inssort(vector<int> &a){ | |
int n = a.size(); | |
for(int j=1; j<n; j++){ | |
int x = a[j]; | |
int k=j; | |
while(--k>=0 && x<a[k]) | |
a[k+1] = a[k]; | |
a[k+1] = x; | |
} | |
} | |
int main(int argc, char *argv[]) { | |
vector<int> v = {10,1,12,3,14,5,16,7,18,9,20,51,22,53,24,55,26,57,28,59}; | |
inssort(v); | |
for(int i:v) cout << i << " "; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment