C++中二维vector赋值
vector<vector<int> > nums(8,vector<int>(13)); //二维数组的行数为8,列数为13。<int>后一定要加一个空格,否则会被判别为操作符>>出错 int b[8][13] = {{0,0,1,0,0,0,0,1,0,0,0,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,1,1,0,1,0,0,0,0,0,0,0,0}, {0,1,0,0,1,1,0,0,1,0,1,0,0}, {0,1,0,0,1,1,0,0,1,1,1,0,0}, {0,0,0,0,0,0,0,0,0,0,1,0,0}, {0,0,0,0,0,0,0,1,1,1,0,0,0}, {0,0,0,0,0,0,0,1,1,0,0,0,0}}; for(int i = 0; i < 8; i++){ for(int j = 0; j < 13; j++){ nums[i][j] = b[i][j]; } }
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: 如何将二维数组赋值给vector
- 下一篇: c++的vector赋值方法汇总