Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <numeric>
- #include <vector>
- #include <algorithm>
- int main() {
- std::vector<int64_t> result(10);
- std::iota(result.begin(), result.end(), 0);
- auto start = std::next(result.begin(), 1);
- auto stop = std::next(result.begin(), 4);
- const int64_t fromptr[10] = {100, 300, 200, 400, 500, 600, 700, 800, 1000, 900};
- std::stable_sort(start, stop, [&fromptr](int64_t i1, int64_t i2) {
- return fromptr[i1] < fromptr[i2];
- });
- //std::transform(start, stop, start, [&](int64_t j) -> int64_t {
- // return j - 3;
- //});
- for(int i=0; i < 10; i++)
- std::cout << result[i] << ' ';
- std::cout << "\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment