|
申请二维数组:vector<vector<int> > array
遍历有三种方法:
vector<int> test
1.通过数组下标遍历
for(int i = 0; i < test.size(); i++) cout<<test[i]<<endl;
2.通过迭代器遍历
for(vector<int>::iterator iter = test.begin(); iter != test.end(); iter++)
cout<<*iter<<endl;
3.通过关键字auto
for(auto it : test) cout<< it << endl;
|