順序棧 基本操作

2021-10-22 21:07:27 字數 1036 閱讀 7955

#include

#include

#define maxsize 10

typedef

struct

sqstack;

//均通過傳遞指標的方式傳參

void

create()

;void

insert

(sqstack *s)

;void

delete

(sqstack *s)

;void

viewdata

(sqstack *s)

;>

intmain()

//建立順序棧棧

void

create()

printf

("初始化棧完成!\n");

viewdata

(s);

//遍歷棧

insert

(s);

//向棧中新增資料

viewdata

(s);

insert

(s);

//再次呼叫,向棧中新增資料

delete

(s);

//從棧頂刪除乙個資料

viewdata

(s);

s->top =-1

;//刪除所有資料

free

(s);

//釋放記憶體

}//新增資料

void

insert

(sqstack *s)}}

//刪除資料

void

delete

(sqstack *s)}}

}//遍歷棧中所用資料

void

viewdata

(sqstack *s)

printf

("當前top為%d\n"

, s->top)

;printf

("*********************\n");

}

順序棧 鏈棧基本操作

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...