Filling and walking a vector
Read · 1 of 3
Two ways to fill a vector
If you know how many: vector<int> a(n); makes n zeros, then cin >> a[i] in a loop.
If you don't: start empty and add to the end with a.push_back(x);.
To visit every value without positions: for (int x : a) { … }.