10.23总结

include

include

using namespace std;

class DoubleStack {

private:

int* arr;       // 共享的数组

int top1;       // 栈1的栈顶指针

int top2;       // 栈2的栈顶指针

int size;       // 数组的总大小

public:

// 构造函数:初始化共享栈

DoubleStack(int s) {

    size = s;

    arr = new int[size];

    top1 = -1;         // 栈1从数组左端开始,初始为空

    top2 = size;       // 栈2从数组右端开始,初始为空

}
posted @ 2025-10-24 11:56  Cx330。  阅读(6)  评论(0)    收藏  举报