附錄(可包括源程式清單或其它說明)
實驗源程式**如下:
第一題:
#include <>
#include <>
#include<>
#define stacksize 100
typedef int stacktype;
typedef structseq_stack;
seq_stack *creatstack()
else
}/*void if_empty(seq_stack *s判斷是否為空棧
*/void push(seq_stack *s,stacktype m入棧操作
else
}stacktype pop(seq_stack *s)
else
}void conver(int n,int i數制轉換
while(s->top>-1)
cout<}
void main()
}第二題:
#include <>
#include <>
#include<>
typedef int stacktype;
typedef struct nodestack_node;
int priority[8][8]=;
stack_node *push(stack_node * t,stacktype m建立同時進行入棧操作
else
return t;
}stack_node *pop(stack_node * t,stacktype *n)
else
}stacktype get_top(stack_node *t讀取棧中資料
else
return t->data;
}int sub(stacktype x)
}void main()
else
opnd=push(opnd,ch-48將數字字元轉換為數字壓入棧中
ch=getchar();
}cout<<"表示式的值為:"<}
第三題:
#include <>
#include <>
#define max 100
typedef struct stack
carstop;
carstop* creat()
{ carstop* s;
s=(stack*)malloc(sizeof(stack));
if(s!=null)
s->top=-1;
資料結構棧和佇列基本操作
實驗二棧和佇列 棧的順尋儲存操作 include stdio.h include stdlib.h define stack init size 100 define stackincrement 10 typedef struct sqstack void initstack sqstack s ...
資料結構 棧與佇列
3311 請判斷下列表示式是否正確。輸入乙個表示式,表示式中包括 字母,數字,括號以及符號 判斷表達中各括號的位置是否遵循以下規則 1 各種括號左右數量相同。2 各種括號只能並列和巢狀,不能交差。輸入 只有一行,為乙個長度小於255的表示式。輸出 一行。如果表示式中各括號互相匹配,則輸出 yes 否...
資料結構03棧的基本操作
院系專業 姓名 林楨曦學號 106052010235 級班年 月 日 編寫棧的基本操作函式 分別用順序和鏈結兩種方式實現 呼叫進棧函式建立乙個棧,讀取棧頂元素,刪除棧中元素,並且輸出棧中所有元素。順序棧 1 建立空棧 int initstack sqstack s 2 進棧 void push sq...