27 lines
488 B
C++
27 lines
488 B
C++
|
// stl 标准模板库开发
|
||
|
// 初次使用:
|
||
|
// vector 存放基础类型的数据示例
|
||
|
#include <iostream>
|
||
|
#include <algorithm>
|
||
|
#include <vector>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
vector<int> v1;
|
||
|
v1.push_back(1);
|
||
|
v1.push_back(2);
|
||
|
v1.push_back(3);
|
||
|
v1.push_back(4);
|
||
|
v1.push_back(5);
|
||
|
v1.push_back(6);
|
||
|
|
||
|
// 创建迭代器
|
||
|
vector<int>::iterator it;
|
||
|
for (it = v1.begin(); it != v1.end(); it++)
|
||
|
{
|
||
|
cout << *it << " ";
|
||
|
}
|
||
|
return 0;
|
||
|
}
|