fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6.  
  7. vector<int> dyn;
  8.  
  9. dyn.resize(1);
  10.  
  11. dyn[0] = 100;
  12.  
  13. cout << dyn.size() << endl;
  14.  
  15. dyn.resize(2);
  16.  
  17. cout << dyn.size() << endl;
  18.  
  19. dyn[1] = 200;
  20.  
  21. cout << dyn[0] << endl;
  22. cout << dyn[1] << endl;
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
1
2
100
200