#include<iostream>
#include<vector>
using namespace std;
int main()
{
int i=0,j=0;
vector <vector <int > > Array;
vector <int> line;
for (j=0; j<10; j++)
{
Array.push_back(line);
for (i=0; i<9; i++)
{
Array[j].push_back(i);
}
}
vector<vector<int > >::iterator iter1;
vector<int> ::iterator iter2;
/****
for (j=0; j<10; j++)
{
for (i=0; i<9; i++)
{
cout <<Array[j][i]<<" ";
}
cout <<endl;
}
cout <<"Array.size()"<<Array.size()<<endl;
cout <<"Array.capacity"<<Array.capacity()<<endl;
****/
/***
vector<int> v;
v.capacity();
v.size();
v.max_size();
v.empty();
v.reserve(n);
v.push_back()
v.pop_back()
v.front()
v.back()
v[i]
v.at(i)
******
vector <int>::iterator iter;
vector <int>::const_iterator con_iter; //const iter
v.begin()
v.end();
v.rbegin();
v.rend();
v.insert(iter,value);
v.insert (iter,n,value);
v.erase(iter);
v.erase(iter1,iter2);
***/
/***** 迭代器遍历二维数组 *******/
for (iter1=Array.begin();iter1!=Array.end();iter1++)
{
for (iter2=(*iter1).begin();iter2!=(*iter1).end();iter2++)
{
cout<< *iter2<<" ";
}
cout <<endl;
}
return 0;
}
vector--初步学习STL
最新推荐文章于 2024-04-04 18:41:54 发布