📄 page_346.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_346</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_345.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_346</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_347.html">next page ></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 346</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">Let's write the two Level 1 modules as void functions, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">GetTemp</font><font face="Times New Roman, Times, Serif" size="3"> and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">PrintActivity</font><font face="Times New Roman, Times, Serif" size="3">, so that the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">main</font><font face="Times New Roman, Times, Serif" size="3"> function looks like the main module of our top-down design. Here is the resulting program.</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 />//聽Activity聽program<br />//聽This聽program聽outputs聽an聽appropriate聽activity<br />//聽for聽a聽given聽temperature<br />//******************************************************************<br />#include聽<iostream.h><br /><br />void聽GetTemp(聽int&聽);聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Function聽prototypes<br />void聽PrintActivity(聽int聽);<br /><br />int聽main()<br />{<br />聽聽聽聽int聽temperature;聽聽聽聽//聽The聽outside聽temperature<br /><br />聽聽聽聽GetTemp(temperature);聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Function聽call<br />聽聽聽聽PrintActivity(temperature);聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Function聽call<br />聽聽聽聽return聽0;<br />}<br /><br />//******************************************************************<br /><br />void聽GetTemp(聽int&聽temp聽)聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Reference聽parameter<br /><br />//聽This聽function聽prompts聽for聽a聽temperature聽to聽be聽entered,<br />//聽reads聽the聽input聽value聽into聽temp,聽and聽echo-prints聽it<br /><br />{<br />聽聽聽聽cout聽<<聽Enter聽the聽outside聽temperature:聽<<聽endl;<br />聽聽聽聽cin聽>>聽temp;<br />聽聽聽聽cout聽<<聽The聽current聽temperature聽is聽聽<<聽temp聽<<聽endl;<br />}<br /><br />//******************************************************************<br /><br />void聽PrintActivity(聽int聽temp聽)聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Value聽parameter<br /><br />//聽Given聽the聽value聽of聽temp,聽this聽function聽prints聽a聽message<br />//聽indicating聽an聽appropriate聽activity<br /><br />{<br />聽聽聽聽cout聽<<聽The聽recommended聽activity聽is聽;<br />聽聽聽聽if聽(temp聽>聽85)<br />聽聽聽聽聽聽聽聽cout聽<<聽swimming.聽<<聽endl;<br />聽聽聽聽else聽if聽(temp聽>聽70)<br /></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_345.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_346</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_347.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -