#include <iostream> #include <vector> using namespace std; int main () { vector<int> myints; cout << "0. size: " << myints.size() << ' '; for (int i=0; i<10; i++) myints.push_back(i); cout << "1. size: " << myints.size() << ' '; myints.insert (myints.end(),10,100);//起始位置,长度,填充元素 cout << "2. size: " << myints.size() << ' '; for (int i=0; i<20; i++) cout << myints[i]<<" "; myints.pop_back(); cout << " 3. size: " << myints.size() << ' '; return 0; }