制作数组堆栈和向量的二维数组
Making a Stack of arrays and 2d arrays of vectors
我正在尝试使用STL堆栈来保存我的变量。我有两个变量声明为vector array[8][8]和int array[8][8]。我该如何声明堆栈?它会像一样吗
stack<vector<int>> array
stack<int>array// not really sure how to use stacks at this point.
编辑:这就是我想做的:
class example
{
private:
vector<int> cells[8][8]//2d array of vectors, one vector for each of the 64 cells
int table[8][8]; //table of 64 elements
//here is what I want to implement
stack<int,vector<int>> cells_stack;// a stack of vectors so that I can backtrack on the vectors if inputs on the table are incorrect
stack<int> table_stack;//stack of array so that I can backtrack;
};
如果我理解正确,您希望将cells
和table
的内容存储在堆栈中。如果这是正确的,那么您要做的就是将堆栈声明为与要存储的对象完全相同。由于cells
是一个类型为vector<int>
的8x8数组,因此cells_stack
应该包含该数组。例如:
stack<vector<int>[8][8]> cells_stack;
table_stack
也是如此,它应该包含类型为int
:的8x8阵列
stack<int[8][8]> table_stack;
相关文章:
- 将值从二维数组输出到文本文件
- 在二维数组中查找最小值和最大值?
- 移动二维数组中的字符
- 如何正确填充在堆上分配的二维数组?
- 传递二维数组时出现问题
- 具有随机数的二维数组不会更改
- 如何在C++中获取二维数组中最少的一列数?
- 如何使用用户输入变量制作二维数组?
- C++ 中动态二维数组的访问冲突
- 遍历二维数组的所有子数组
- 将二维数组的所有元素插入到一维数组中
- 在函数中传递二维数组
- 为什么指针在对二维数组进行排序时无法正常工作?
- 创建 std::string 的二维数组的最佳做法
- 如何将文本文件读取到二维数组中并以 c++ 打印
- 元素在二维数组 c++ 中的出现次数
- 执行 c++ 二维数组
- C++ 中的二维数组初始化为一个值
- 制作数组堆栈和向量的二维数组
- 将字符串的二维数组和向量作为参数传递给函数