fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. vector <int> myVec = { 5, 12, 521, 9 };
  10.  
  11. for ( auto it : myVec )
  12. cout << it << endl;
  13.  
  14. for_each( begin(myVec), end(myVec), [&](const int & ref){
  15. cout << 2*ref << endl;
  16. });
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
5
12
521
9
10
24
1042
18