- 12
- 0
- 约3.59万字
- 约 8页
- 2017-06-08 发布于河南
- 举报
数据结构 3.2.2链栈完成括号的匹配(国外英文资料)
数据结构 3.2.2链栈实现括号的匹配(国外英文资料)
The 3.2.2 stack implements the parentheses match
/ * * * chain stack implementation bracket matching * * /
# include iostream
Using namespace STD.
1 # define OK
# define the ERROR 0
# define OVERFLOW - 2
Typedef char SElemType;
Typedef int the Status;
Typedef struct SNode {
The int data;
Struct SNode * next;
} SNode, * LinkStack;
The Status InitStack (LinkStack S)
{
S = NULL;
Return OK;
}
Bool StackEmpty (LinkStack S)
{
If (! S)
Return true;
Return false;
}
Status Push (LinkStack S, SElemType e)
{
SNode * p = new SNode;
If (!) p
{
Return OVERFLOW;
}
P minus data = e;
P minus , next = S;
S = p;
Return OK;
}
Status Pop (LinkStack S, SElemType e)
{
SNode * p;
If (! S)
Return the ERROR;
E is equal to S minus data.
P = S;
S = s- next;
The delete p;
Return OK;
}
Status GetTop (LinkStack S, SElemType e)
{
If (! S)
Return the ERROR;
E is equal to S minus data.
Return OK;
}
/ / the match for the 3.9 bracket of the algorithm
The Status Matching (LinkStack S)
{
/ / verify that the parentheses in the expression are correctly matched, or false if the match returns true.
/ / the expression ends in #
Int flag = 1; / / tags find results to control loop and return results
Char c;
SElemType x;
Cin c; / / read the first character
While (c! = # flag)
{
The switch (c) {
Case [ :
Case ( : / / if left parenthesis, press it into the stack
Push (S, c);
Break;
Case ) : / / if the right parenthesis is), it is considered based on the value of the current stack top element
GetTop (S, x);
If (! StackEmpty (S) x = = = = = () / / if the stack is not empty and the stack top element is (, the match is successful
Pop (S, x);
The else
Flag = 0; / / if the stack empty or stack top element is not (, it is illegal
Break;
Case : / / if the right parenthesis is, it is considered based on the value of the current stack top element
GetTop (S, x);
If (! StackEmpty (S) x = = = = =) / / if the top element of the stack is [, the match is successful
Pop (S, x);
The e
您可能关注的文档
- 幼儿园幼儿教员练习日记(国外英文资料).doc
- 幼儿园教授教化的运动性绳尺及应用(国外英文资料).doc
- 幼儿园教授教化运动设计 步调-写法(国外英文资料).doc
- 幼儿园教授教化目标的制订(国外英文资料).doc
- 幼儿园朗诵节目《我们的故事》(国外英文资料).doc
- 幼儿园月考语(国外英文资料).doc
- 幼儿园练习判定考语(国外英文资料).doc
- 幼儿园小班游戏观察迟疑记录(国外英文资料).doc
- 幼儿园英语措辞情况的主要性(国外英文资料).doc
- 幼儿园集体备课的环节和教师备课新架构(国外英文资料).doc
- 2025-2026学年天津市和平区高三(上)期末数学试卷(含解析).pdf
- 2025-2026学年云南省楚雄州高三(上)期末数学试卷(含答案).pdf
- 2025-2026学年甘肃省天水市张家川实验中学高三(上)期末数学试卷(含答案).docx
- 2025-2026学年福建省厦门市松柏中学高二(上)期末数学试卷(含答案).docx
- 2025-2026学年广西钦州市高一(上)期末物理试卷(含答案).docx
- 2025-2026学年河北省邯郸市临漳县九年级(上)期末化学试卷(含答案).docx
- 2025-2026学年河北省石家庄二十三中七年级(上)期末历史试卷(含答案).docx
- 2025-2026学年海南省五指山市九年级(上)期末化学试卷(含答案).docx
- 2025-2026学年河北省唐山市玉田县九年级(上)期末化学试卷(含答案).docx
- 2025-2026学年河北省邢台市市区九年级(上)期末化学试卷(含答案).docx
最近下载
- 课件第3讲gps伪距测量原理.pptx VIP
- 焊割工操作安全培训内容课件.pptx VIP
- 蚌埠市博物馆展览陈列大纲.pdf VIP
- 《爷爷的爷爷从哪里来》整本书阅读 课件 四年级下册语文(统编版).pptx VIP
- 指南共识│咯血诊治专家共识.pptx
- 博物馆陈列展览大纲精编.docx VIP
- Q/GDW 376.1-2009《电力用户用电信息采集系统通信协议:主站与采集终端通信协议》及编制说明1.doc VIP
- 阀门电动执行装置设计毕业设计(论文).doc VIP
- 中考数学二轮复习 专题11 二次函数与矩形、菱形的存在性问题(知识解读)(解析版).doc VIP
- 博物馆陈列展览大纲(2019最新版).docx VIP
原创力文档

文档评论(0)