Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void my_sort(auto &a, auto cmp, auto my_swap)
- {
- for (int i = 0; i < a.size(); ++i)
- {
- auto prev = begin(a);
- for (auto j = begin(a); j != end(a); ++j)
- {
- if (cmp(*j, *prev))
- my_swap(*j, *prev);
- prev = j;
- }
- }
- }
- int main()
- {
- vector<int> a;
- int n = 10;
- for (int i = 0; i < n; ++i)
- a.push_back(i);
- my_sort(a,
- [](auto a, auto b)
- {
- return a > b;
- },
- [](auto &a, auto &b)
- {
- a ^= b ^= a ^= b;
- }
- );
- for (int i = 0; i < n; ++i)
- cout << a[i] << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement