#include #include #include #include #include using namespace std; void main(){ vector v; cout << "size " << v.size() << " cap "; cout << v.capacity() << endl; v.push_back("knee"); v.push_back("antimony"); v.push_back("cring"); v.push_back("sparingly"); v.push_back("at"); cout << "size " << v.size() << " cap "; cout << v.capacity() << endl; v[3] = "bird whistle"; for(int i = 0; i < static_cast(v.size()); i++) cout << i << " " << v[i] << endl; vector vi(5); cout << "size " << vi.size() << " cap "; cout << vi.capacity() << endl; vi.push_back(42); cout << "size " << vi.size() << " cap "; cout << vi.capacity() << endl; for(int i = 0; i < static_cast(vi.size()); i++) cout << i << " " << vi[i] << endl; sort(v.begin(),v.end()); vector::iterator it; cout << "using iterator notation" << endl; for(it = v.begin(); it != v.end(); it++) cout << *it << endl; list L; L.push_back(4); L.push_back(6); L.push_back(2); L.sort(); list::iterator il; cout << "using iterator notation" << endl; for(il = L.begin(); il != L.end(); il++) cout << *il << endl; cout << "Matrix:" << endl; vector > matrix(3); matrix[0].push_back(17); matrix[0].push_back(26); matrix[0].push_back(42); matrix[1].push_back(12); matrix[1].push_back(19); matrix[1].push_back(99); matrix[1].push_back(89); matrix[2].push_back(34); matrix[2].push_back(77); matrix[2].push_back(13); for(int i = 0; i < static_cast(matrix.size()); i++){ for(int j = 0; j < static_cast(matrix[i].size()); j++){ cout << matrix[i][j] << " "; } cout << endl; } cout << "Vector of Lists" << endl; vector > compound(2); list list3; compound.push_back(list3); compound[0].push_back(17); compound[0].push_back(26); compound[0].push_back(42); compound[1].push_back(12); compound[1].push_back(19); compound[1].push_back(99); compound[1].push_back(89); compound[2].push_back(34); compound[2].push_back(77); compound[2].push_back(13); list::iterator ci; for(int i = 0; i < static_cast(compound.size()); i++){ for(ci = compound[i].begin(); ci != compound[i].end(); ci++){ cout << *ci << " "; } cout << endl; } }