fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. int main() {
  5. auto n = 10;
  6.  
  7.  
  8. // dont use "a{n, 0}"" initialization, because that means: "construct a vector with the two int values inside"
  9. std::vector<int> a(n, 0);
  10.  
  11.  
  12. int i{};
  13. for (auto x : a) std::cout << i++ << ":" << x << "\n";
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0s 5260KB
stdin
Standard input is empty
stdout
0:0
1:0
2:0
3:0
4:0
5:0
6:0
7:0
8:0
9:0