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

📄 page_1130.html

📁 Programming and Problem Solving with C++
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">	<html>		<head>			<title>page_1130</title>			<link rel="stylesheet" href="reset.css" type="text/css" media="all">			<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />		</head>		<body>		<table summary="top nav" border="0" width="100%">			<tr>				<td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1129.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_1130</strong></td>				<td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1131.html">next page&nbsp;&gt;</a></td>			</tr>					<tr>				<td align="left" colspan="3" style="background: #ffffff; padding: 20px;">    <table border="0" width="100%" cellpadding="0"><tr><td align="center">  <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td>  <td align="right"></td>  </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 1130</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="3">It's hard to believe that such a simple algorithm actually works, but we'll prove it to you. Following is a driver program that calls the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">DoTowers</font><font face="Times New Roman, Times, Serif" size="3"> function. Output statements have been added so you can see the values of the actual parameters with each recursive call. Because there are two recursive calls within the function, we have indicated which recursive statement issued the call.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td>  <td colspan="3" height="12"></td>  <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td>  <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">//******************************************************************<br />//聽TestTowers聽program<br />//聽This聽program,聽a聽test聽driver聽for聽the聽DoTowers聽function,聽reads聽in<br />//聽a聽value聽from聽standard聽input聽and聽passes聽this聽value聽to聽DoTowers<br />//******************************************************************<br />#include聽&lt;iostream.h&gt;<br />#include聽&lt;iomanip.h&gt;聽聽聽聽//聽For聽setw()<br /><br />void聽DoTowers(聽int,聽int,聽int,聽int聽);<br /><br />int聽main()<br />{<br />聽聽聽聽int聽circleCount;聽聽聽聽//聽Number聽of聽circles聽on聽starting聽peg<br /><br />聽聽聽聽cout聽&lt;&lt;聽Input聽number聽of聽circles:聽;<br />聽聽聽聽cin聽&gt;&gt;聽circleCount;<br />聽聽聽聽cout聽&lt;&lt;聽OUTPUT聽WITH聽&lt;&lt;聽circleCount聽&lt;&lt;聽聽CIRCLES聽&lt;&lt;聽endl<br />聽聽聽聽聽聽聽聽聽&lt;&lt;聽endl;<br />聽聽聽聽cout聽&lt;&lt;聽CALLED聽FROM聽聽#CIRCLES聽&lt;&lt;聽setw(8)聽&lt;&lt;聽BEGIN<br />聽聽聽聽聽聽聽聽聽&lt;&lt;聽setw(8)聽&lt;&lt;聽AUXIL.聽&lt;&lt;聽setw(5)聽&lt;&lt;聽END<br />聽聽聽聽聽聽聽聽聽&lt;&lt;聽聽聽聽聽INSTRUCTIONS聽&lt;&lt;聽endl<br />聽聽聽聽聽聽聽聽聽&lt;&lt;聽endl;<br />聽聽聽聽cout聽&lt;&lt;聽Original聽聽聽:;<br />聽聽聽聽DoTowers(circleCount,聽1,聽2,聽3);<br />聽聽聽聽return聽0;<br />}<br /><br />//******************************************************************<br /><br />void聽DoTowers(<br />聽聽聽/*聽in聽*/聽int聽circleCount,聽聽聽聽//聽Number聽of聽circles聽to聽move<br />聽聽聽/*聽in聽*/聽int聽beginPeg,聽聽聽聽聽聽聽//聽Peg聽containing聽circles聽to聽move<br />聽聽聽/*聽in聽*/聽int聽auxPeg,聽聽聽聽聽聽聽聽聽//聽Peg聽holding聽circles聽temporarily<br />聽聽聽/*聽in聽*/聽int聽endPeg聽聽聽聽聽聽聽)聽聽//聽Peg聽receiving聽circles聽being聽moved<br /><br />//聽This聽recursive聽function聽moves聽circleCount聽circles聽from聽beginPeg<br />//聽to聽endPeg.聽聽All聽but聽one聽of聽the聽circles聽are聽moved聽from聽beginPeg<br />//聽to聽auxPeg,聽then聽the聽last聽circle聽is聽moved聽from聽beginPeg聽to聽endPeg,<br />//聽and聽then聽the聽circles聽are聽moved聽from聽auxPeg聽to聽endPeg.<br />//聽The聽subgoals聽of聽moving聽circles聽to聽and聽from聽auxPeg聽are聽what<br />//聽involve聽recursion</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>  </td>			</tr>				<tr>				<td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1129.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_1130</strong></td>				<td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_1131.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

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