数据结构::线性表实现栈
#includeusing namespace std; #define MaxSize 10 typedef struct{ int data[MaxSize]; int top; }Sqstack; //初始化栈 void InitStack(Sqstack &S) { S.top=-1; } bool StackEmpty(Sqstack S) { if(S.top == -1) return true; else return false; } bool Push(Sqstack &S,int x) { if(S.top == MaxSize-1) return false; S.data[++S.top]=x; return true; } bool Pop(Sqstack &S,int &x) { if(S.top==-1) return false; x=S.data[S.top--]; return true; } bool GetPop(Sqstack S,int &x) { if(S.top==-1) return false; x=S.data[S.top]; return true; } int main() { Sqstack S; InitStack(S); cout< 暑期编程PK赛 得CSDN机械键盘等精美礼品!



