Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Use this tag when arranging items in order is the main focus of the code.
4
votes
3
answers
916
views
Insertion sort C++14 implementation
vector<int> &v);
void print(const std::vector<int> &v);
int main()
{
std::ios_base::sync_with_stdio(false);
std::vector<int> v {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
// Print the vector before sorting … print(v);
// Sort
insertionSort(v);
// Print the vector after sorting.
print(v);
return 0;
}
void insertionSort(std::vector<int> &v) {
for (auto i = v.begin() + 1; i ! …
6
votes
3
answers
951
views
Merge sort C++14 implementation
false);
std::vector<int> v;
int temp = 0;
while (std::cin >> temp) {
v.push_back(temp);
}
// Sort
mergeSort(v, v.begin(), v.end() - 1);
// Print the vector after sorting …