⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用栈实现迷宫问题求解_数据结构与算法_数据结构算法_c语言_c 语言之家.htm

📁 严蔚民版的数据结构的完整课件
💻 HTM
📖 第 1 页 / 共 5 页
字号:
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">}//StackEmpty<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">Status Push(Stack 
                              &amp;S,SElemType e){<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt"><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-spacerun: yes">&nbsp;</SPAN>//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">插入元素</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">e</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">为新的栈顶元素</SPAN><SPAN 
                              lang=EN-US 
                              style="FONT-SIZE: 9pt"><o:p></o:p></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>if(S.top-S.base 
                              &gt;=S.stackSize){//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">栈满,加空间</SPAN><SPAN 
                              lang=EN-US 
                              style="FONT-SIZE: 9pt"><o:p></o:p></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>S.base=(SElemType 
                              *)realloc(S.base,(S.stackSize+INCREMENT)*sizeof(SElemType));<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>if(!S.base)<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>exit(OVERFLOW);<SPAN 
                              style="mso-spacerun: yes">&nbsp;&nbsp; 
                              </SPAN>//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">存储分配失败</SPAN><SPAN 
                              lang=EN-US 
                              style="FONT-SIZE: 9pt"><o:p></o:p></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>S.top=S.base+S.stackSize;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>S.stackSize+=INCREMENT;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>}<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>*S.top++=e;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>return OK;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">}//push<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt 18pt; TEXT-INDENT: -18pt; mso-char-indent-count: -2.0"><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">Status Pop(Stack 
                              &amp;S,SElemType &amp;e){//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">若栈不空删除栈</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">顶元素用</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">e</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">返回并返回</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">OK</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,否则返回</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">ERROR<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>if(S.top==S.base)<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>return ERROR;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>e=*--S.top;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>return OK;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">}//Pop<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">Status DestroyStack(Stack 
                              &amp;S){//</FONT></SPAN><SPAN 
                              style="FONT-FAMILY: 宋体; FONT-SIZE: 9pt; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">销毁栈</SPAN><SPAN 
                              lang=EN-US style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">S,<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>free(S.base);<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>S.top=S.base;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman"><SPAN 
                              style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                              </SPAN>return OK;<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">}//DestroyStack<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><o:p><FONT 
                              face="Times New Roman">&nbsp;</FONT></o:p></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">//maze.cpp<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 
                              style="FONT-SIZE: 9pt"><FONT 
                              face="Times New Roman">#include 
                              "stack.h"<o:p></o:p></FONT></SPAN></P>
                              <P class=MsoNormal 
                              style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -