fork download
  1. #include <algorithm>
  2. #include <array>
  3. #include <iostream>
  4.  
  5. int main() {
  6. std::array<int, 5> a = { 1, 2, 3, 4, 5 };
  7. std::for_each(a.begin(), a.begin() + 3, [](int &n){
  8. std::cout << n << '\n';
  9. });
  10. return 0;
  11. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
1
2
3