#include
using namespace std;
#include
#include
//状态类
class State
{
private:
int x;
int y;
int z;
public:
State(int a, int b, int c) //定义构造函数
{
x = a;
y = b;
z = c;
}
void print() //定义打印方法
{
printf("%d %d %d\n", x, y, z);
}
};
stack<State> path;
int main()
{
State s1 = State(0, 1, 2);
State s2 = State(3, 4, 5);
State s3 = State(2, 2, 2);
State s4 = State(0, 1, 3);
//测试数据入栈
path.push(s1);
path.push(s2);
path.push(s3);
path.push(s4);
printf("path的大小:%d\n", path.size());
//遍历出栈
while (path.empty() == 0)
{
path.top().print();
path.pop();
}
return 0;
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)