freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

數(shù)據(jù)結(jié)構(gòu)--3章棧和隊(duì)-文庫(kù)吧資料

2024-08-18 07:33本頁(yè)面
  

【正文】 i=Pop( amp。 //余數(shù)入棧 N=N/B。 //初始化棧 while( N ){ //N=0轉(zhuǎn)換結(jié)束 push( amp。 InitStack(amp。 void szzh( int N,int B ) { int i。 使用不帶表頭結(jié)點(diǎn)的單鏈表 (1)結(jié)點(diǎn)和指針的定義 struct node { ElemType data; //data為抽象元素類(lèi)型 struct node *next; //next為指針類(lèi)型 } *top=NULL; //初始化 ,置 top為 空棧 (2)非空鏈?zhǔn)綏?的一般形式 an a(n1) a1 ^ data next top 棧頂 棧底 (3)鏈?zhǔn)綏5?進(jìn)棧算法 : //壓入元素 e到 top為頂指針的鏈?zhǔn)綏? struct node *push_link(struct node *top,Elemtype e) { struct node *p; int leng=sizeof(struct node); //確定新結(jié)點(diǎn)空間的大小 p=(struct node *)malloc(leng); //生成新結(jié)點(diǎn) pdata=e; //裝入元素 e pnext=top; //插入新結(jié)點(diǎn) top=p; //top指向新結(jié)點(diǎn) return top; //返回指針 top } an a1 ^ 棧底 top e p X an a1 ^ 棧底 top e ... ... 棧頂 棧頂 (1)插入 e之前: (2)插入 e之后: 棧的應(yīng)用舉例 棧的基本用途 保存暫時(shí)不用 的數(shù)據(jù)或存儲(chǔ)地址。 2. 出棧和讀棧頂元素操作,先判斷棧是否為空,為空時(shí)不能操作,否則產(chǎn)生錯(cuò)誤。 } 以下幾點(diǎn)說(shuō)明: 1. 對(duì)于順序棧,入棧時(shí),首先判斷棧是否滿(mǎn)了,棧滿(mǎn)的條件為: stop= =StackSize1,棧滿(mǎn)時(shí),不能入棧 。/*返回 ,棧頂指針減 1 */ } (6) 取棧頂元素 datatype Top_SeqStack(SeqStack *s) { if ( EmptyStack ( s ) ) Error(“Stack is empty”)。 } (5) 出棧 DataType Pop(SeqStack *s, datatype *x) { if (StackEmpty ( s ) ) Error(“Stack underflow”)。 /*棧滿(mǎn)不能入棧 */ stop++。 } (2)判空棧 int StackEmpty (SeqStack *s) {return Stop= =1。 stop= 1。 SeqStack *InitStack() { SeqStack *s。 棧的存儲(chǔ)表示和操作實(shí)現(xiàn) 用順序空間表示的棧。 int top。 (1)初始狀態(tài) C B A (2)A,B,C進(jìn)棧 B A (3)C出棧 C A,B,C (4)輸入 A,B,C,不能產(chǎn)生輸出 C,A,B: 設(shè)依次輸入元素 A,B,C到棧中 ,可得哪幾種輸出 ? 設(shè)依次輸入元素 C,B,A到棧中 ,可得哪幾種輸出 ? A,B,C (1) A,B,C (2) A,C,B (3) B,A,C (4) B,C,A (5) C,A,B (6) C,B,A C,B,A (1) A,B,C (2) A,C,B (3) B,A,C (4) B,C,A (5) C,A,B (6) C,B,A 討論 : 假定輸入元素 A,B,C,D 到棧中 ,能得當(dāng)哪幾種輸出 ? 不能得到哪幾種輸出序列? (1) A,B,C,D (7) B,A,C,D (13) C,A,B,D (1
點(diǎn)擊復(fù)制文檔內(nèi)容
公司管理相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1