1 #include 2#define stacksize 50/*設棧中元素個數為50個*/
3using
namespace
std;45
struct
seqstack6;
1011
/*構造乙個空棧
*/12
void initstack(seqstack *s)
1316
17/*
將x置入s棧新棧頂
*/18
bool push(seqstack *s,int
x)19
2627
/*將s棧頂元素彈出,放到x所指的儲存空間中帶出
*/28
bool pop(seqstack * s,int &x)
2936
37/*
將棧s棧頂元素讀出,放到x所指的儲存空間中,棧頂指標保持不變
*/38
bool gettop(seqstack * s, int &x)
3945
46/*
將棧清空
*/47
void clearstack(seqstack *s)
4851
52/*
判斷棧s是否為空
*/53
bool isempty(seqstack *s)
5459
60/*
判斷棧s是否已滿
*/61
bool isfull(seqstack *s)
6268
69/*
列印棧s所有元素
*/70
void
printstack(seqstack s)
7176
77int
main()
順序棧 基本操作
include include define maxsize 10 typedef struct sqstack 均通過傳遞指標的方式傳參 void create void insert sqstack s void delete sqstack s void viewdata sqstack s ...
順序棧 鏈棧基本操作
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...