STL库_vector容器使用记录
作者:互联网
vector二维使用
int mode = 6;
//注意 > 前面的空格不要少
vector<vector<int> > ivec(mode); //6行,在后面循环插入的时候定义列
//插入值
for (int i2 = 0; i2 < ivec.size(); i2++) { //行
for (int i = 0; i <= 3; i++) { //列
ivec[i2].push_back(99);
}
}
//遍历输出值
for (int i = 0; i < mode; i++) {
cout << endl<<"行: " << i << ": ";
for (vector<int>::const_iterator p = ivec[i].begin(); p != ivec[i].end(); p++) {
cout << *p<<" ";
}
}
标签:容器,ivec,STL,i2,++,int,vector,mode 来源: https://blog.csdn.net/a15322910600/article/details/120579807