- //文件名:CHAPTER5-4.cpp
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {vector<int> coll; // vector 容器 for integer elements
- int i;
- // append elements with values 1 to 6
- for (i=1; i<=6; ++i) { coll.push_back(i);}
- // print all elements followed by a space
- for (i=0; i<coll.size(); ++i) { cout << coll[i] << ' '; }
- cout << endl;
- return 1;
- }