fork download
  1. #include<vector>
  2. #include<iostream>
  3. #include<initializer_list>
  4. using namespace std;
  5. int main(void){
  6. vector<int> nn={0,1,2,3,4};
  7. for(int i=0; i<10; i++){
  8. int& n(nn[i]); // this is just to save typing, and is not used if invalid
  9. if(i<nn.size()) cout<<n<<endl;
  10. }
  11. };
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
0
1
2
3
4