目錄
//要注意初始化時,形參的那個引用符號(&)必須要加上!否則初始化就用雙指標來做!
//其他操作的函式在形參列表裡可以不用加上引用符號(&)
#include#include#include#includeconst int maxsize=100;
typedef struct
sqstack;
//初始化,就是給指標分配乙個空間
void initstack(sqstack *&s)
//銷毀棧
void destorystack(sqstack *s)
//入棧操作
bool push(sqstack *s,int element)
}//出棧操作
bool pop(sqstack *s)
//取棧頂元素
bool gettop(sqstack *s,int *element)
}int main()
; for(int i=0;i<9;i++)
while(gettop(s,element))
return 0;
}
//帶頭結點的單鏈表
//根據棧的特性,肯定是用的頭插法
#include#includeusing namespace std;
typedef struct linknode
linkstack;
void initstack(linkstack *&s)
void destorystack(linkstack *s)
free(pre);
}void push(linkstack *s,int e)
bool pop(linkstack *s)
bool gettop(linkstack *s,int *e)
int main()
; int *element;
for(int i=0;i<9;i++)
while(gettop(s,element))
return 0;
}
順序棧 鏈棧基本操作
include stdafx.h include stdio.h include stdlib.h define stack max size 7 int stackdata stack max size define stack max size 14 int stackdata stack ma...
順序棧 鏈棧基本操作
include stdafx.h include stdio.h include stdlib.h define stack max size 7 int stackdata stack max size define stack max size 14 int stackdata stack ma...
順序棧 鏈棧基本操作
include stdafx.h include stdio.h include stdlib.h define stack max size 7 int stackdata stack max size define stack max size 14 int stackdata stack ma...