03栈的基本操作之括号匹配,进制转换(03, the basic operation of the stack bracket matching, hexadecimal conversion).docVIP
- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
03栈的基本操作之括号匹配,进制转换(03, the basic operation of the stack bracket matching, hexadecimal conversion)
03栈的基本操作之括号匹配,进制转换(03, the basic operation of the stack bracket matching, hexadecimal conversion)
括号匹配
# includes stdio.h
# includes string.h
# includes stdlib.h
# define mixsize 100
# define stackincrement 100
typedef char datatype;
typedef struct
{
datatype date [mixsize];
int top;
seqstack}; / / 定义结构体
/ / 初始化
void stackinitiate (seqstack * s)
{
s - top = 0;
}
/ / 判断是否为空
int stacknotempty (seqstack d)
{
if (s.top = 0)
return 0;
else return 1;
}
/ / 入栈
int stackpush (seqstack * s, datatype x)
{
if (s - = mixsize)
{
printf (栈满, 无法输入 \ n);
return 0;}
else {
s - date [s - top] = x;
s - top + +;
return 1;
}
}
/ / 出栈
int stackpop (seqstack * s, datatype * d)
{
if (s - = 0)
{
printf (栈空 \ n);
return 0;
}
else
{
s - top -.
* d = s - (s - [top];
return 1;
}
}
int stacktop (seqstack s, datatype * d) / / 取栈顶元素.若栈s非空, 则返回栈顶元素, 但不改变栈的状态.
{
if (s.top = 0)
{printf (栈已空! \ n);
return 0;
}
else
{
* d = s.data [s.top-1];
return 1;
}
}
/ / 括号匹配算法
void kuohaopipei (char [mixsize])
/ / 判断有n个字符的的字符串a左、右括号是否配对正确
{
seqstack mystack;
int i;
char c;
stackinitiate ( mystack);
for (i = 0; [i]. = \ 0; i + +)
{
if (a [i] = = = () | | (a [i] = = [) | | (a [i] = = 0)
stackpush ( mystack, []); / / 入栈
else if (a [i] = =) stacknotempty (mystack) stacktop (mystack, c) c = = ()
stackpop ( mystack, c).
else if (a [i] = =) stacknotempty (mystack) stacktop (mystack, c) c! = ()
{
printf (此串括号匹配不合法! \ n);
return;
}
else if (a [i] = = =] stacknotempty (mystack) stacktop (mystack, c) c = = )
stackpop ( mystack, c).
else if (a [i] = = =] stacknotempty (mystack) stacktop (mystack, c) c! = = [
{
printf (此串括号匹配不合法! \ n); return;
}
else if (a [i] = = 1) | | (a [i] = =)) ! stacknotempty (mystack))
{
printf (此串括号匹配不合法! \ n); return;
}
if (a [i] = =} stacknotempty (mystack) stacktop (mystack, c) c = = {)
stackpop ( mystack, c).
else if (a [i] = =} stacknotempty (mystack) stacktop (mystack, c) c! =})
{
printf (此串括号匹配不合法! \ n);
return;
}
}
if (stacknote
您可能关注的文档
- (学普6-1)网络答疑((general 6-1) network answering).doc
- (中文和英文)求职应聘自我介绍范例((Chinese and English) apply for self introduction example).doc
- (电大毕业论文范文)对于艺术伪艺术,真商业党校毕业论文范文((TV University Thesis) for art, pseudo art, real business school).doc
- (附)约翰·法雷尔形象分析之成长篇((attached) the growth chapter of John Farrell's image analysis).doc
- (建筑工程)第1章2((construction) chapter first 2).doc
- (不是很完美)select列表项关联((not perfect) select list item association).doc
- ((人教版))[[初一数学试题]]新人教版初一数学上册期末考试(含答案)...(((PEP)) test of junior mathematics new edition junior mathematics book final exam (with answers)...).doc
- (德中轮)浅谈救助遇险锚泊船的体会(Talking about the experience of rescue distress mooring ship).doc
- (经典)手动挡驾驶技巧((Classic) manual driving skills).doc
- (跑跑卡丁车)技术心得 -- 跑跑卡丁车(Technical experience (running kart) - run kart).doc
- 0321中国文化概论-08年1月自考试题整合答案(0321 introduction to Chinese culture, -08 January self test questions integrated answer).doc
- 00部分常用卫星天线接收器密码(出厂初始密码)(The 00 part is the password of common satellite antenna receiver (initial password)).doc
- 03级给水排水(03 stage water supply and drainage).doc
- 013 i++和++i的效率差别(013 efficiency difference between i++ and ++i).doc
- 04-05年下学期七年级单元同步测试地理巴西a卷(附答案)(04-05 next semester, unit seven, simultaneous testing, geography Brazil a (with answers)).doc
- 04养生论(04 health preserving theory).doc
- 04技术分析精要(Analysis of 04 key technology).doc
- 05-2-2黑桥牌也开始卖德国香肠了(05-2-2 black bridge also began to sell German sausage).doc
- 05月-qcc持续改善活动推进(05, -qcc continuous improvement activities to promote).doc
- 0607【头脑风暴】关键词分析法(0607 brainstorm keyword analysis).doc
最近下载
- 水闸横剖面图识读水利工程图识读与绘制.pptx VIP
- 国家建筑标准设计图集20S515 钢筋混凝土及砖砌排水检查井.pdf VIP
- 救援技术毕业论文题目(647个).doc VIP
- l临床医生三基考试试题及答案.doc VIP
- 苏教版高一生物必修一知识点总结.doc VIP
- 12J7-3-内装修吊顶标准规范(OCR).pdf VIP
- 全国翻译专业资格(水平)考试--CATTI精品课件.ppt VIP
- 《深化国有企业改革》课件.ppt VIP
- 基于AI技术的增强型汽车动力电池预测方法及系统.pdf VIP
- (2025秋新版)部编版三年级道德与法治上册《第10课《公共场所的文明素养》 教学设计.docx VIP
原创力文档


文档评论(0)