Skip to content

Commit

Permalink
Merge pull request srbcheema1#30 from harjot3200/master
Browse files Browse the repository at this point in the history
Sorting A Vector Algo srbcheema1#4
  • Loading branch information
srbcheema1 authored Oct 1, 2017
2 parents 3b1e177 + 9de89c9 commit e9afc43
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions sorting_a_vector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

bool compare(int a,int b){
return a>b;
}

int main(){

vector<int> v;

for(int i=1;i<5;i++){
v.push_back(i);
}
int p;
cin>>p;

int d;
cin>>d;

v.insert(v.begin() + p,d);

for(int i=0;i<v.size();i++){
cout<<v[i]<<" ";
}
cout<<endl;
///Sort a vector
sort(v.begin(),v.end(),compare);

for(int i=0;i<v.size();i++){
cout<<v[i]<<" ";
}



return 0;
}

0 comments on commit e9afc43

Please sign in to comment.