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

📄 page_408.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_408</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_407.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_408</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_409.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 408</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="Courier New, Courier, Mono New, Courier, Mono" size="2">//聽Precondition:<br />//聽聽聽聽聽1聽&lt;=聽month聽&lt;=聽12<br />//聽聽&amp;&amp;聽dayOfMonth聽is聽in聽valid聽range聽for聽the聽month<br />//聽聽&amp;&amp;聽year聽is聽assigned<br />//聽Postcondition:<br />//聽聽聽聽聽Function聽value聽==聽day聽number聽in聽the聽range聽1聽聽365<br />//聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽(or聽1聽聽366聽for聽a聽leap聽year)<br /><br />{<br />聽聽聽int聽correction;聽聽聽聽//聽Correction聽factor聽to聽account聽for聽leap聽year<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽and聽months聽of聽different聽lengths<br /><br />聽聽聽//聽Test聽for聽leap聽year<br /><br />聽聽聽if聽(year聽%聽4聽==聽0聽&amp;&amp;聽(year聽%聽100聽!=聽0聽||聽year聽%聽400聽==聽0))<br />聽聽聽{<br />聽聽聽聽聽聽聽if聽(month聽&gt;=聽3)聽聽聽聽聽聽聽聽聽//聽If聽date聽is聽after聽February聽29<br />聽聽聽聽聽聽聽聽聽聽聽correction聽=1;聽聽聽聽聽聽//聽聽聽then聽add聽one聽for聽leap聽year<br />聽聽聽}<br />聽聽聽else<br />聽聽聽聽聽聽聽correction聽=聽0;<br /><br />聽聽聽//聽Correct聽for聽different聽length聽months<br /><br />聽聽聽if聽(month聽==聽3)<br />聽聽聽聽聽聽聽correction聽=聽correction聽-聽1;<br />聽聽聽else聽if聽(month聽==聽2聽||聽month聽==聽6聽||聽month聽==聽7)<br />聽聽聽聽聽聽聽correction聽=聽correction聽+聽1;<br />聽聽聽else聽if聽(month聽==聽8)<br />聽聽聽聽聽聽聽correction聽=聽correction聽+聽2;<br />聽聽聽else聽if聽(month聽==聽9聽||聽month聽==聽10)<br />聽聽聽聽聽聽聽correction聽=聽correction聽+聽3;<br />聽聽聽else聽if聽(month聽==11聽||聽month聽==聽12)<br />聽聽聽聽聽聽聽correction聽=聽correction聽+聽4;<br />聽聽聽return聽(month聽-聽1)聽*聽30聽+聽correction聽+聽dayOfMonth;<br />}</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="Times New Roman, Times, Serif" size="3">The first thing to note about the function definition is that it looks like a void function, except for the fact that the heading begins with the data type </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3"> instead of the word </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">void</font><font face="Times New Roman, Times, Serif" size="3">. The second thing to observe is the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">return</font><font face="Times New Roman, Times, Serif" size="3"> statement at the end, which includes an integer expression between the word </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">return</font><font face="Times New Roman, Times, Serif" size="3"> and the semicolon.</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="Times New Roman, Times, Serif" size="3">A value-returning function returns one value, not through a parameter but by means of a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">return</font><font face="Times New Roman, Times, Serif" size="3"> statement. The data type at the beginning of the heading declares the type of value that the function will return. This data type is called the <i>function type,</i> although a more proper term is function value type (or <i>function return type</i> or <i>function result type).</i></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_407.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_408</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_409.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

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