fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector<int> a = { 1, 2, 3, 4, 5};
  9. vector<int> b;
  10.  
  11. transform(a.begin(), a.end()-1, a.begin()+1, back_inserter(b), plus<int>());
  12.  
  13. for (auto elem : b)
  14. cout << elem << " ";
  15.  
  16. // your code goes here
  17. return 0;
  18. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
3 5 7 9