實驗二棧和佇列
//棧的順尋儲存操作
#include "stdio.h"
#include "stdlib.h"
#define stack_init_size 100
#define stackincrement 10
typedef struct sqstack;
void initstack(sqstack &s)
void push(sqstack &s,int e)
int pop(sqstack &s)
/*void conversion()//數制轉換
printf("轉換的八進位制為:");
while(
printf("\n");
}void main()
*/void main()
printf("初始化的棧出棧為:");
while(
printf("\n");
}//鏈棧的基本操作(括號的匹配檢查)
#include "stdio.h"
#include "stdlib.h"
typedef struct snode
snode,*linkstack;
//初始化棧
void init(linkstack &top)
//建立棧
void creat(linkstack &top,int n)
}//進棧操作
void push(linkstack &top,char e)
//出棧操作
void pop(linkstack &top,char &e)
void display(linkstack &top)
printf("\n");
}//測試程式
void main()
else if(a==']')
}if(stack1->next==null)
printf("括號匹配!\n");
}//鏈佇列的基本操作
#include "stdio.h"
#include "stdlib.h"
typedef int qelemtype;
typedef struct qnode qnode,*queueptr;
typedef struct linkqueue;
//構造乙個空佇列 q
void initqueue(linkqueue &q)
void enqueue(linkqueue &q,int e)
void dequeue(linkqueue &q,int &e)
void main()
printf("出隊的元素為:");
while(!(q.front==q.rear))
}//應用棧和佇列判斷回文
#include "stdio.h"
#include "stdlib.h"
//棧typedef struct snode
snode,*linkstack;
//初始化棧
void initlinkstack(linkstack &top)
//進棧操作
void push(linkstack &top,char e)
//出棧操作
void pop(linkstack &top,char &e1)
//佇列
typedef struct qnode qnode,*queueptr;
typedef struct linkqueue;
//構造乙個空佇列 q
void initqueue(linkqueue &q)
void enqueue(linkqueue &q,char e)
void dequeue(linkqueue &q,char &e2)
//回文判斷函式
int huiwen(linkstack &s,linkqueue &q)
if(e1!=e2)}
資料結構棧或佇列的基本操作
附錄 可包括源程式清單或其它說明 實驗源程式 如下 第一題 include include include define stacksize 100 typedef int stacktype typedef structseq stack seq stack creatstack else voi...
資料結構實驗棧和佇列
實驗二第三章棧和佇列 一 棧 實驗原始碼 include include include define stack init size 100 define stackincrement 10 typedef int selemtype typedef int status typedef stru...
資料結構 棧與佇列
3311 請判斷下列表示式是否正確。輸入乙個表示式,表示式中包括 字母,數字,括號以及符號 判斷表達中各括號的位置是否遵循以下規則 1 各種括號左右數量相同。2 各種括號只能並列和巢狀,不能交差。輸入 只有一行,為乙個長度小於255的表示式。輸出 一行。如果表示式中各括號互相匹配,則輸出 yes 否...