書式#include <iostreamの>
の#include <ベクトル>
名前空間stdを使用。
INTメイン()
{
ベクトル<整数> VEC1。
用(int型のk = 0; K <20; kは++)
{
vec1.push_back(K)。
COUT << "サイズ" << vec1.size()<< "容量:" << vec1.capacity()<< ENDL。
}
システム(「一時停止」)。
0を返します。
}
===============================================
サイズ:1容量:1
サイズ:2容量:2
サイズ:3容量:3
サイズ:4容量:4
サイズ:5容量:6
サイズ:6容量:6
サイズ:7容量:9
サイズ:8容量:9
サイズ: 9容量:9
サイズ:10容量:13
サイズ:11容量:13
サイズ:12容量:13
サイズ:13容量:13
サイズ:14容量:19
サイズ:15容量:19
サイズ:16容量:19
サイズ:17容量:19
サイズ:18容量:19
サイズ:19容量:19
サイズ:20容量:28
请按任意键继续。。。