fork download
  1. #include <algorithm>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6. int arr[5] = { 1, 2, 3, 4, 5 };
  7.  
  8. std::transform(arr, arr + 5, arr, [](int i) { return i + 2; });
  9.  
  10. for (const auto& i : arr)
  11. {
  12. std::cout << i << "\n";
  13. }
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
3
4
5
6
7