下载
加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 栈和队列及其应用(实验三)

栈和队列及其应用(实验三).doc

栈和队列及其应用(实验三)

据说恋爱回来过_
2017-09-29 0人阅读 举报 0 0 暂无简介

简介:本文档为《栈和队列及其应用(实验三)doc》,可适用于活动策划领域

栈和队列及其应用(实验三)实验三栈和队列及其应用一(实验目的及要求()掌握栈和队列这两种特殊的线性表熟悉它们的特性在实际问题背景下灵活运用它们()本实验训练的要点是“栈”的观点及其典型用法()掌握问题求解的状态表示及其递归算法以及由递归程序到非递归程序的转化方法。二(实验内容()编程实现栈在两种存储结构中的基本操作(栈的初始化、判栈空、入栈、出栈等)()应用栈的基本操作实现数制转换(任意进制)()编程实现队列在两种存储结构中的基本操作(队列的初始化、判队列空、入队列、出队列)()利用栈实现任一个表达式中的语法检查(括号的匹配)。()利用栈实现表达式的求值。三(实验主要流程、基本操作或核心代码、算法片段(该部分如不够填写请另加附页)()编程实现栈在两种存储结构中的基本操作(栈的初始化、判栈空、入栈、出栈等)程序代码部分:顺序存储头文件:#defineSTACKINITSIZE#defineSTACKINCREMENT#defineOK#defineERROR#defineTRUE#defineFALSE#defineINFEASTALE#defineOVERFLOW功能函数:typedefintStatustypedefintSElemTypetypedefstruct{SElemType*baseSElemType*topintstacklength}SqstackStatusInit(SqstackS)StatusDestroy(SqstackS)StatusClear(SqstackS)StatusEmpty(SqstackS)intLength(SqstackS)StatusGetTop(SqstackS,SElemTypee)StatusPush(SqstackS,SElemTypee)StatusPop(SqstackS,SElemTypee)#include"stdioh"#include"stdlibh"#include"h"StatusInit(SqstackS){Sbase=(SElemType*)malloc(STACKINITSIZE*sizeof(SElemType))if(!Sbase)exit(OVERFLOW)Stop=SbaseSstacklength=STACKINITSIZEreturnOK}StatusDestroy(SqstackS){Sbase=returnOK}StatusClear(SqstackS){Sbase=StopreturnOK}StatusEmpty(SqstackS){if(Sbase==Stop){returnTRUE}elsereturnFALSE}intLength(SqstackS){returnStopSbase}StatusGetTop(SqstackS,SElemTypee){if(Sbase==Stop)returnERRORe=*(Stop)returnOK}StatusPush(SqstackS,SElemTypee){if(StopSbase>=STACKINITSIZE){Sbase=(SElemType*)realloc(Sbase,(SstacklengthSTACKINCREMENT)*sizeof(SElemType))if(!Sbase)exit(OVERFLOW)Stop=SbaseSstacklengthSstacklength=STACKINCREMENT}*Stop=ereturnOK}StatusPop(SqstackS,SElemTypee){if(Sbase==Stop)exit(ERROR)e=*StopreturnOK}主函数:#include"stdioh"#include"stdlibh"#include"h"intmain(){printf("是否创建空栈,n")printf("、创建n、退出n")inta选择scanf("d",a)if(a==)exit(ERROR)SqstackSInit(S)intlengthprintf("请确定元素个数n")scanf("d",length)printf("请输入具体元素(空格隔开)n")intd用于循环for(d=d<lengthd){scanf("d",Stop)Stop}intb选择功能do{printf("请选择下列功能:n")printf("、销毁栈n")printf("、置空栈n")printf("、判空n")printf("、栈的长度n")printf("、取栈顶元素n")printf("、插入新的栈顶元素n")printf("、删除栈顶元素n")printf("、结束程序n")scanf("d",b)switch(b){case:{Destroy(S)printf("栈已销毁")}breakcase:{Clear(S)printf("栈已清空n")}breakcase:{inta承载返回值a=Empty(S)if(a==){printf("此栈为空n")}elseprintf("此栈不为空n")}breakcase:{printf("此时栈的长度为:dn",Length(S))}breakcase:{SElemTypeeGetTop(S,e)printf("此时的栈顶元素为:dn",e)}breakcase:{inteprintf("请输入新的栈顶元素n")scanf("d",e)Push(S,e)SElemType*pp=Sbaseprintf("此时栈中元素有:n")while(p!=Stop){printf("d",*p)p}printf("n")}breakcase:{SElemTypeePop(S,e)SElemType*pp=Sbaseprintf("被删除的栈顶元素为:dn",e)printf("此时栈中元素为:n")while(p!=Stop){printf("d",*p)p}printf("n")}breakcase:printf("程序结束~n")breakdefault:printf("输入错误n")}}while(b!=b!=)if(b==){printf("若需进行其他功能则要重启程序新建空栈n")}return}链式存储头文件:#defineOK#defineERROR#defineTRUE#defineFALSEtypedefintStatustypedefintSElemTypetypedefstructLNode{SElemTypedatastructLNode*next}LNode,*LinkListStatusInit(LinkListSL,intnum)StatusPush(LinkListSL,inte,intnum)StatusPop(LinkListSL,inte,intnum)StatusGet(LinkListSL)StatusClear(LinkListSL,intnum)voidEmply(LinkListSL)功能函数:#include"stdioh"#include"h"#include"stdlibh"StatusInit(LinkListSL,intnum){printf("请输入相应个数的各个具体元素(空格隔开)n")SL=(LinkList)malloc(sizeof(LNode))scanf("d",SL>data)SL>next=for(inti=i<numi){LinkLists=s=(LinkList)malloc(sizeof(LNode))scanf("d",s>data)s>next=SLSL=s}returnOK}StatusGet(LinkListSL){returnSL>data}StatusClear(LinkListSL,intnum){if(SL==)printf("该栈本就为空n")returnERRORwhile(!SL){LinkListp=SLif(p>next!=){SL=p>nextfree(p)}else{free(SL)}}if(SL==){num=printf("该栈已清空n")}else{printf("清空功能没有正常完成~n")}returnOK}voidEmply(LinkListSL){if(SL==){printf("该栈为空n")}else{printf("该栈不为空n")}}StatusPush(LinkListSL,inte,intnum){LinkLists=s=(LinkList)malloc(sizeof(LNode))s>data=es>next=SLSL=snumreturnOK}StatusPop(LinkListSL,inte,intnum){e=SL>dataLinkListss=SLSL=SL>nextfree(s)numreturnOK}主函数:#include"stdioh"#include"stdlibh"#include"h"intmain(){printf("是否建立链栈,n")printf("、建立n")printf("、不建立并退出程序n")inta选择建立scanf("d",a)switch(a){case:{LinkListSL=intnum用户确定的元素个数printf("请确定元素个数n")scanf("d",num)Init(SL,num)printf("此时的链栈中元素为(从栈顶到栈底):n")LinkListb=SLfor(inti=i<numi){printf("d",b>data)b=b>next}printf("n")printf("请选择以下功能:n")intx用于选择功能do{printf("、入栈n")printf("、出栈n")printf("、查看栈顶元素n")printf("、清空栈n")printf("、判空n")printf("、查看栈的长度n")printf("、结束程序n")scanf("d",x)switch(x){case:{printf("请输入新的栈顶元素n")intdata用户输入的新的栈顶元素scanf("d",data)Push(SL,data,num)printf("此时的链栈中元素为(从栈顶到栈底):n")LinkListb=SLfor(inti=i<numi){printf("d",b>data)b=b>next}printf("n")}breakcase:{inte用于承载栈顶元素Pop(SL,e,num)printf("出栈的元素为:dn",e)printf("此时栈中的元素有(从栈顶到栈底):n")LinkListb=SLfor(inti=i<numi){printf("d",b>data)b=b>next}printf("n")}breakcase:{printf("此时的栈顶元素为:dn",Get(SL))}breakcase:{Clear(SL,num)}breakcase:{Emply(SL)}breakcase:{printf("此时栈长为:dn",num)}breakcase:printf("程序结束~n")breakdefault:printf("程序输入错误~n")}}while(x!=)}breakcase:printf("程序结束~n")breakdefault:printf("输入错误~n")}return},运行结果:()应用栈的基本操作实现数制转换(任意进制)程序代码部分:头文件:#defineOK#defineERROR#defineTRUE#defineFAULSE#defineOVERFL#defineFEASIBLE#defineINIT#defineINCRtypedefintStatustypedefintSElemTypetypedefstruct{SElemType*topSElemType*baseintstacksize}StackvoidInit(StackS)voidPush(StackS,SElemTypee)StatusPop(StackS,SElemTypee)StatusEmpty(StackS)voiddtoother(inta,intd)voidothertod(inta,intc)intothertod(inta,intc)voidothertoother(inta,intc,intd)voidxiaoshudtoother(doublep,intd)voiddtoother(inta,intd)功能函数:#include"stdioh"#include"stdlibh"#include"h"创建栈voidInit(StackS){Sbase=(SElemType*)malloc(INIT*sizeof(SElemType))if(!Sbase)exit(OVERFL)Stop=SbaseSstacksize=INIT}入栈voidPush(StackS,SElemTypee){if(StopSbase>=Sstacksize){Sbase=(SElemType*)realloc(Sbase,(INCRINIT)*sizeof(SElemType))if(!Sbase)exit(OVERFL)Stop=SbaseSstacksizeSstacksize=INCR}*Stop=e}StatusPop(StackS,SElemTypee){if(Sbase==Stop)returnERRORe=*StopreturnOK}判空StatusEmpty(StackS){if(Sbase==Stop){returnOK}elsereturnERROR}十进制整数转换成其他进制voiddtoother(inta,intd)用户输入的十进制数的整数部分和目的进制{StackSInit(S)intmwhile(a){m=adPush(S,m)a=ad}inteprintf("该数对应的d进制为:n",d)while(!Empty(S)){Pop(S,e)if(e>){printf("c",e'A')}else{printf("d",e)}}printf("n")}其他进制数转换为十进制voidothertod(inta,intc)用户输入的其他进制数和该数的进制{intbintn,d=,e=余数其他进制数各个位对应的十进制其他进制数的第几位几位转换成十进制的和while(a){b=adif(b==d>){n=for(inti=di>i){n=c*n}e=en}elseif(b==d==){n=e=en}elseif(b==){a=acontinue}a=a}printf("该数对应的十进制数为:n")printf("dn",e)}其他进制数转换为十进制(只用于其他功能函数内)intothertod(inta,intc)用户输入的其他进制数和该数的进制{intbintn,d=,e=余数其他进制数各个位对应的十进制其他进制数的第几位几位转换成十进制的和while(a){b=adif(b==d>){n=for(inti=di>i){n=c*n}e=en}elseif(b==d==){n=e=en}elseif(b==){a=acontinue}a=a}returne}其他进制转换为其他进制voidothertoother(inta,intc,intd)用户输入的数原数进制目的进制{intg承载该数转化后的十进制数g=othertod(a,c)dtoother(g,d)}十进制整数转换成其他进制(只用于含小数部分的十进制整数)voiddtoother(inta,intd)用户输入的十进制数的整数部分和目的进制{StackSInit(S)intmwhile(a){m=((int)a)dPush(S,m)a=ad}SElemTypeeprintf("该数对应的d进制为:n",d)while(!Empty(S)){Pop(S,e)if(e>){printf("c",e'A')}else{printf("d",e)}}}小数部分:十进制转换成其他进制voidxiaoshudtoother(doublep,intd)小数部分和目的进制{inta用于存放已经转化了的位inti=while(p){ai=(int)floor(p*d)p=p*d(double)aiiif(i>=){printf("该小数可能不能转化为有限的d进制的数n",d)exit(ERROR)}}StackQInit(Q)SElemTypeewhile(i){Push(Q,ai)i}while(!Empty(Q)){Pop(Q,e)if(e>){printf("c",e'A')}else{printf("d",e)}}printf("n")}主函数:#include"stdioh"#include"h"#include"stdlibh"intmain(){intkdo{printf("请选择一下操作n")printf("、数制转换n")printf("、结束程序n")scanf("d",k)if(k==){intc=,d=用户选择原数进制、目的数进制printf("请输入是几进制变为几进制(空格隔开)n")scanf("dd",c,d)if(c==){printf("确定输入的数据的性质n")printf("、整数n")printf("、含有小数部分n")inthscanf("d",h)switch(h){case:{printf("请输入源十进制整数n")intascanf("d",a)dtoother(a,d)break}case:{doublea=,p=用户输入一个数(非负)、该数小数部分、inti=整数部分printf("请输入十进制实数n")scanf("lf",a)i=(int)ap=aidtoother(i,d)printf("")xiaoshudtoother(p,d)break}default:printf("输入错误n")}}if(d==){intaprintf("请输入d进制数:n",c)scanf("d",a)othertod(a,c)}if(c!=d!=){intaprintf("请输入d进制数:n",c)scanf("d",a)othertoother(a,c,d)}}else{printf("程序结束~n")}}while(k!=)return},运行结果:()编程实现队列在两种存储结构中的基本操作(队列的初始化、判队列空、入队列、出队列),程序代码:顺序存储头文件:#defineOK#defineERROR#defineTRUE#defineFALSE#defineOVERFLOW#defineINFEASIBLE#defineMAXtypedefintStatustypedefintQElemTypetypedefstruct{QElemType*baseintfrontintrear}SqQueueStatusInit(SqQueueQ)StatusENQueue(SqQueueQ,QElemTypee)StatusOUTQueue(SqQueueQ,QElemTypee)StatusClearQueue(SqQueueQ)StatusEmpty(SqQueueQ)功能函数:#include"stdioh"#include"stdlibh"#include"h"StatusInit(SqQueueQ){Qbase=(QElemType*)malloc(sizeof(QElemType)*MAX)if(!Qbase)exit(OVERFLOW)Qfront=Qrear=returnOK}StatusENQueue(SqQueueQ,QElemTypee){if((Qrear)MAX==Qfront){returnERROR}QbaseQrear=eQrear=(Qrear)MAXreturnOK}StatusOUTQueue(SqQueueQ,QElemTypee){if(Qrear==Qfront)returnERRORe=QbaseQfrontQfront=(Qfront)MAXreturnOK}StatusClearQueue(SqQueueQ){while(Qrear!=Qfront){Qfront=(Qfront)MAX}returnOK}StatusEmpty(SqQueueQ){if(Qfront!=Qrear)returnERRORreturnOK}主函数:#include"stdioh"#include"h"intmain(){printf("是否创建队列,n")printf("、创建n")printf("、结束程序n")intascanf("d",a)if(a==){return}else{SqQueueQif(Init(Q)==OK){printf("队列初始化完毕最大容量为dn",MAX)}else{printf("队列初始化失败程序结束n")returnERROR}intbdo{printf("选择下列操作n")printf("、入队n")printf("、出队n")printf("、清空队n")printf("、判空队n")printf("、结束程序n")scanf("d",b)switch(b){case:{printf("请输入要插入的元素个数n")intnumscanf("d",num)printf("请输入要插入的元素:n")QElemTypeeintresultfor(inti=i<numi){scanf("d",e)result=ENQueue(Q,e)if(result==ERROR){printf("队列已满第d个元素无法再存入n",i)}}inta=Qfront,b=Qrearprintf("此时队列中的元素分别为:n")while(a!=b){printf("d",Qbasea)a=(a)MAX}printf("n")printf("n")printf("n")printf("n")break}case:{QElemTypeeintresultresult=OUTQueue(Q,e)if(result==ERROR){printf("此队列为空当前没有元素n")}else{printf("此时头元素为:dn",e)}inta=Qfront,b=Qrearprintf("此时队列中的元素分别为:n")while(a!=b){printf("d",Qbasea)a=(a)MAX}printf("n")printf("n")printf("n")printf("n")break}case:{intresultresult=ClearQueue(Q)if(result==OK){printf("队列已清空n")}else{printf("队列清空失败n")}printf("n")printf("n")printf("n")break}case:{intresultresult=Empty(Q)if(result==OK){printf("此队列为空n")}else{printf("此队列不为空n")}printf("n")printf("n")printf("n")break}case:printf("程序结束~n")breakdefault:printf("输入错误!n")}}while(b!=)}}链式存储头文件:#defineOK#defineERROR#defineOVERFLOWtypedefintStatustypedefintQElemTypetypedefstructQNode{structQNode*nextQElemTypedata}QNode,*Queuetypedefstruct{QueuefrontQueuerear}LinkQueueStatusInit(LinkQueueQ)voidENQueue(LinkQueueQ,QElemTypee)StatusDEQueue(LinkQueueQ,QElemTypee)StatusClear(LinkQueueQ)StatusEmpty(LinkQueueQ)功能函数:#include"stdioh"#include"stdlibh"#include"h"StatusInit(LinkQueueQ){Qfront=Qrear=(Queue)malloc(sizeof(QNode))if(!Qfront)exit(OVERFLOW)Qfront>next=returnOK}voidENQueue(LinkQueueQ,QElemTypee){QueuesQueuep=Qrears=(Queue)malloc(sizeof(QNode))if(!s){printf("分配存储空间失败n")exit(OVERFLOW)}s>data=es>next=Qrear>next=sQrear=sp>next=s}StatusDEQueue(LinkQueueQ,QElemTypee){if(Qfront==Qrear){returnERROR}e=Qfront>next>dataQueues=Qfront>nextQfront>next=s>nextfree(s)returnOK}StatusClear(LinkQueueQ){Queueswhile(Qfront>next!=Qrear){s=Qfront>nextQfront>next=s>nextfree(s)}s=Qrearfree(s)Qrear=QfrontQfront>next=returnOK}StatusEmpty(LinkQueueQ){if(Qfront==QrearQfront>next==){returnOK}else{returnERROR}}主函数:#include"stdioh"#include"stdlibh"#include"h"intmain(){printf("是否建立队列n")printf("、建立n")printf("、不建立并结束程序n")intascanf("d",a)if(a==){intnumLinkQueueQif(Init(Q)==){printf("队列初始化成功n")}else{printf("队列初始化失败程序结束n")exit()}printf("请选择一下功能n")intbdo{printf("、入队列n")printf("、出队列n")printf("、清空队列n")printf("、队列判空n")printf("、结束程序n")scanf("d",b)switch(b){case:{printf("请确定入队元素个数n")scanf("d",num)printf("请输入具体元素n")intefor(inti=i<numi){scanf("d",e)ENQueue(Q,e)}printf("此时的队列中元素分别为:n")Queuep=Qfront>nextfor(intj=j<numj){printf("d",p>data)p=p>next}printf("n")printf("n")break}case:{QElemTypeeintresultresult=DEQueue(Q,e)if(result==OK){printf("队列中头元素为:dn",e)numprintf("此时的队列中元素分别为:n")Queuep=Qfront>nextfor(intj=j<numj){printf("d",p>data)p=p>next}printf("n")printf("n")}else{printf("此时的队列为空没有元素能取出n")returnERROR}printf("n")printf("n")break}case:{if(Clear(Q)==OK){printf("队列已清空n")}else{printf("队列清空失败n")}printf("n")printf("n")break}case:{if(Empty(Q)==OK){printf("该队列为空n")}else{printf("该队列不为空n")}printf("n")printf("n")break}case:printf("程序结束n")breakdefault:printf("输入错误n")}}while(b!=)}elseif(a==){printf("程序结束n")return}else{printf("输入错误n")exit()}return},运行结果:()利用栈实现任一个表达式中的语法检查(括号的匹配)。,程序代码:头文件:#defineOK#defineERROR#defineOVERFLOW#definesizetypedefintStatustypedefcharSElemTypetypedefstruct{SElemType*baseSElemType*topintStacksize}SqStackStatusInit(SqStacks)StatusENStack(SqStacks,SElemTypee)StatusDEStack(SqStacks,SElemTypee)功能函数:#include"stdioh"#include"stdlibh"#include"h"StatusInit(SqStacks){sbase=(SElemType*)malloc(sizeof(SElemType)*size)if(!sbase)exit(OVERFLOW)stop=sbasereturnOK}StatusENStack(SqStacks,SElemTypee){if((stopsbase)>=size){SElemType*newbasenewbase=(SElemType*)realloc(sbase,sizeof(SElemType)*(sStacksizesize))if(!newbase)exit(OVERFLOW)sbase=newbasesStacksize=size}*stop=ereturnOK}StatusDEStack(SqStacks,SElemTypee){if(sbase==stop){returnERROR}e=*stopreturnOK}主函数:#include"stdioh"#include"stdlibh"#include"h"intmain(){SqStackssStacksize=sizeif(Init(s)==OK){printf("已经成功初始化一个空栈n")}else{printf("栈的初始化失败n")exit(ERROR)}printf("请输入要检测的表达式(各个符号间用空格隔开,以#表示输入完成)n")SElemTypeasizefor(inti=i<sizei){scanf("c",ai)if(ai=='#'){break}if(ai=='('||ai==''||ai=='{'){ENStack(s,ai)}if(ai==')'||ai==''||ai=='}'){SElemTypeeDEStack(s,e)if(ai==')'){if(e!='('){printf("该表达式括号匹配不正确n")returnERROR}}if(ai==''){if(e!=''){printf("该表达式括号匹配不正确n")returnERROR}}if(ai=='}'){if(e!='{'){printf("该表达式括号匹配不正确n")returnERROR}}}}printf("该表达式括号匹配正确n")returnOK},运行结果:()利用栈实现表达式的求值。未完成头文件:#defineOK#defineERROR#defineOVERFLOW#definesizetypedefintStatustypedefcharSElemTypetypedefstruct{SElemType*baseSElemType*topintstacksize}SqStackStatusInit(SqStackS)StatusENStack(SqStackS,SElemTypee)StatusDEdStack(SqStackS,SElemType*e)StatusDEsStack(SqStackS,SElemTypee)SElemTypeGetStack(SqStackS,SElemTypee)SElemTypecmp(SElemTypee,SElemTypee)功能函数:#include"stdioh"#include"stdlibh"#include"h"栈的初始化StatusInit(SqStackS){Sbase=(SElemType*)malloc(sizeof(SElemType)*size)if(!Sbase){printf("存储空间分配失败n")exit(OVERFLOW)}Stop=SbaseSstacksize=sizereturnOK}入栈StatusENStack(SqStackS,SElemTypee){if(StopSbase>=Sstacksize){SElemType*newbasenewbase=(SElemType*)realloc(Sbase,sizeof(SElemType)*(Sstacksizesize))if(!newbase){printf("新增存储空间失败n")exit(OVERFLOW)}Sbase=newbaseStop=SbaseSstacksizeSstacksize=size}*Stop=ereturnOK}数值出栈StatusDEdStack(SqStackS,SElemType*e){if(Sbase==Stop){printf("此时栈为空n")returnERROR}e=StopreturnOK}算符出栈StatusDEsStack(SqStackS,SElemTypee){if(Sbase==Stop){printf("此时栈为空n")returnERROR}e=*StopreturnOK}查看栈顶元素SElemTypeGetStack(SqStackS,SElemTypee){if(Sbase==Stop){printf("栈为空n")returnERROR}SElemType*pp=Stope=*preturne}算符优先关系查询SElemTypecmp(SElemTypee,SElemTypee){charbinti,jb='>'b='>'b='<'b='<'b='<'b='>'b='>'b='>'b='>'b='<'b='<'b='<'b='>'b='>'b='>'b='>'b='>'b='>'b='<'b='>'b='>'b='>'b='>'b='>'b='>'b='<'b='>'b='>'b='<'b='<'b='<'b='<'b='<'b='='b=''b='>'b='>'b='>'b='>'b=''b='>'b='>'b='<'b='<'b='<'b='<'b='>'b=''b='='if(e=='')i=if(e=='')i=if(e=='*')i=if(e=='')i=if(e=='(')i=if(e==')')i=if(e=='#')i=if(e=='')j=if(e=='')j=if(e=='*')j=if(e=='')j=if(e=='(')j=if(e==')')j=if(e=='#')j=returnbij}主函数:#include"stdioh"#include"stdlibh"#include"h"intmain(){ints=表达式的最终结果SqStackD,S数据栈、算符栈Init(D)printf("数据栈初始化成功n")Init(S)printf("算符栈初始化成功n")charasizeprintf("请输入表达式(每个数值和符号都用空格隔开并以#表示输入结束)n")for(inti=i<sizei){scanf("c",ai)if(ai!=''ai!=''ai!='*'ai!=''ai!='('ai!=')'ai!='#'){ENStack(D,ai)}if(ai==''||ai==''||ai=='*'||ai==''||ai=='('||ai==')'||ai=='#'){chare承载返回的算符关系charc承载栈顶算符if(Stop==Sbase){ENStack(S,ai)}else{e=cmp(GetStack(S,c),ai)if(e=='>'){DEsStack(S,c)char*dchar*f承载第一个,第二个取出的数值(在算符右边、左边的)DEdStack(D,d)DEdStack(D,f)intg该步骤下得到的结果if(c==''){g=atoi(f)atoi(d)}if(c==''){g=atoi(f)atoi(d)}if(c=='*'){g=atoi(f)*atoi(d)}if(c==''){g=atoi(f)atoi(d)}s=sgENStack(S,ai)}elseif(e=='<'){ENStack(S,ai)}}}if(ai=='#'){break}}printf("该表达式的结果为:dn",s)return}四(实验结果的分析与评价(该部分如不够填写请另加附页)栈的链式存储无需头结点队列的顺序存储采用循环的方式以rear=front作为判空条件rear=(front)maxsize作为队满的条件注:实验成绩等级分为(,分)优(,分)良(分)中(,分)及格(分)不及格。

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/67

栈和队列及其应用&#40;实验三&#41;

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利