📄 ds3.2习题.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>数 据 结 构</title>
<meta name="Microsoft Theme" content="hounk 010">
</head>
<body background bgcolor="#000099" text="#CCCC99" link="#FF9900" vlink="#996600" alink="#FF3300">
<!--mstheme--><font face="宋体">
<p:colorscheme
colors="#0000FF,#FFFFFF,#000000,#FFCC66,#00FFFF,#3366FF,#FF0033,#FFFF00"/>
<p align="center"><b><font face="oúì?,SimHei" lang="ZH-CN" color="#FFFFFF" size="6">第三章习题</font></b></p>
<p class="MsoNormal"><span lang="EN-US"><b><font size="5" color="#FFFFFF">2.</font></b></span><b><font size="5" color="#FFFFFF"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">设以数组</span><span lang="EN-US">se[m]</span><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">存放循环队列的元素,同时设变量</span><span lang="EN-US">rear
</span><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"">和</span><span lang="EN-US">front</span><span style="font-family:
宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"">分别作为队头队尾指针,且队头指针指向队头前一个位置,写出这样设计的循环队列入队出队的算法</span><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">。</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"">解答:</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">int
Outseq(</span></font></b><font size="5" color="#FFFFFF"><b>SeQueue *sq</b></font><b><font size="5" color="#FFFFFF">,elemtype
x<span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">)</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">{</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0">
<font size="5" color="#FFFFFF"><b>if(sq.rear==sq.front) return 0;</b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> sq.front++;</b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> x=sq.data[sq.front];</b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> return
1; </b></font></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">}</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"> </p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">int
Inseq(</span></font></b><font size="5" color="#FFFFFF"><b> SeQueue *sq</b></font><b><font size="5" color="#FFFFFF">,elemtype
x<span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">)</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">{</span></font></b></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0">
<font size="5" color="#FFFFFF"><b>if(sq.rear==sq.front) return 0; </b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> sq.rear++;</b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> sq.data[sq.rear]=x;</b></font></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> return
1; </b></font></p>
<p class="MsoNormal" align="left" style="margin-top: 0; margin-bottom: 0"><b><font size="5" color="#FFFFFF"><span style="font-family: 宋体; mso-ascii-font-family: Times New Roman; mso-hansi-font-family: Times New Roman">}</span></font></b></p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"> </p>
<p ALIGN="JUSTIFY" style="margin-top: 0; margin-bottom: 0"><font size="5" color="#FFFFFF"><b> </b></font></p>
<p class="MsoNormal" align="center"><b><a href="ds3习题.HTM"><font size="5" color="#FFFF00">返回</font></a></b></p>
<!--mstheme--></font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -