棧的儲存結構(一)順序棧
棧的儲存結構(二)雙端棧
棧的儲存結構(三)鏈棧
棧的運用(一)無括號表示式求值
棧的運用(二)無括號表示式求值修正版
#include
#include
#define maxsize 100
//雙端棧需要有2個棧頂指標 底在2端
typedef
struct stackstack,
*stackp;
//這樣乙個底在0處,乙個底在maxsize-1處
//初始化需要把2個top至於2底端
void
initialstack
(stackp *st)
//入棧 帶選擇
intpushstack
(stackp st)
else
}else
}getchar()
;}else
if(num==1)
else
}else
}getchar()
;}return0;
}void
printstack
(stackp st)
printf
("\n另一端為\n");
int p=maxsize-1;
for(
;p>=st->top[1]
;p--)}
intpopstack
(stackp st)
else
}else
if(num==1)
else
}printstack
(st);}
void
main()
資料結構 雙端棧
定義 乙個線性表的兩端當做棧底分別進行入棧和出棧的操作,主要利用了棧 棧底位置不變,而棧頂位置動態變化 的特性。我們把雙端棧叫做arraydoubleendstack,雙端棧是線性表的一種,更是棧的乙個特殊的分類,所以我們可以用動態陣列和棧的思想來實現雙端棧,畢竟由於其操作的特殊性,並不能借助arr...
資料結構 棧 棧的鏈式儲存結構
資料結構 棧 棧的鏈式儲存結構 用頭插法建立的鏈棧,棧頂元素為s next所指結點 date 2017 4 14 include include define initsize 100 define elemtype char typedef struct lnode linkstack void ...
資料結構 鏈棧(棧的鏈式儲存結構)
工程目錄結構 函式的返回結果,ok erreo true false 12 typedef int elemtype 結點資料域的資料型別 1314 endif common.c 1 include common.h 2 3status visit elemtype e 4linkstack.h 1...