資料結構模板 棧

2021-09-24 20:37:04 字數 1140 閱讀 6821

此部落格是存的是我自己編寫的棧模板,如有錯誤請指出
棧是操作受限的線性表,只允許在棧頂進行插入和刪除操作,遵循「後進先出」原則。
#include

#include

#define elemtype int

#define maxsize 1000

using namespace std;

///這是順序棧的模板

typedef

struct

sqstack;

void initstack (sqstack *

&s)void

destroystack

(sqstack *

&s)bool stackempty

(sqstack *s)

bool push

(sqstack *

&s,elemtype e)

bool pop

(sqstack *

&s,elemtype &e)

bool gettop

(sqstack *

&s,elemtype &e)

intmain()

#include

#include

#define elemtype int

using namespace std;

typedef

struct linknode

linkstnode;

void

initstack

(linkstnode *

&s)void

destroystack

(linkstnode *

&s)free

(pre);}

bool stackempty

(linkstnode *

&s)void

push

(linkstnode *

&s,elemtype s)

bool pop

(linkstnode *

&s,elemtype &e)

intmain()

c 資料結構 模板類重寫棧

模板重寫棧的基本操作,不多說,上 不足之處,麻煩大神指點。基本操作如下 bool is empty my stack a 是否為空棧 t gettop my stack a 獲取棧頂元素 void stack push my stack a,t b 入棧 t stack pop my stack a...

資料結構模板 佇列

此部落格是存的是我自己編寫的佇列模板,如有錯誤請指出佇列是操作受限的線性表,只允許在隊頭進行刪除操作,在隊尾進行插入操作,遵循 先進先出 原則。順序隊 存在假溢位問題 include include define elemtype int define maxsize 1000 using name...

資料結構模板合集

線段樹lazy操作模板 區間修改,區間查詢 class segment tree lazy inline void add int p,int v,int t inline void pushdown int p,int l,int r public inline void build tree i...