c++ primer 9.4节练习

9.38 vector的增长

//*******************9.4节练习*********************
//*******************9.38 vector的增长*************************
vector<int> ivec;
int s, c;


for (int i = 0; i < 15; i++)
{
    for (s = ivec.size(), c = ivec.capacity(); s <= c; s++)
        ivec.push_back(1);
    cout << "分配的内存空间: " << ivec.capacity() << " 元素个数: " << ivec.size() << endl;
}

std::system("pause");
return 0;