Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <numeric>
- using namespace std;
- int main(){
- vector<int> a(10,1);
- adjacent_difference(a.begin(), std::prev(a.end()), std::next(a.begin()), std::plus<> {});
- copy(a.begin(), a.end(), std::ostream_iterator<int> {std::cout, " "});
- cout << endl;
- vector<int> b{0,2,5,4,2};
- adjacent_difference(b.begin(), std::prev(b.end()), next(b.begin()) , std::plus<> {});
- copy(b.begin(), b.end(), std::ostream_iterator<int> {std::cout, " "});
- return 0;
- }
- 1 1 2 3 5 8 13 21 34 55
- 0 0 0 0 0
- Process finished with exit code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement