📄 page_738.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_738</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_737.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_738</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_739.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 738</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">void聽WritePerCandidate(<br />聽聽聽聽聽聽聽/*聽in聽*/聽聽聽聽const聽VoteTable聽votes,聽聽聽聽聽聽聽聽聽//聽Total聽votes<br />聽聽聽聽聽聽聽/*聽in聽*/聽聽聽聽const聽String10聽聽name[],聽聽聽聽聽聽聽聽//聽Candidate聽names<br />聽聽聽聽聽聽聽/*聽inout聽*/聽ofstream&聽聽聽reportFile聽)聽聽聽聽聽聽聽//聽Output聽file<br /><br />//聽Sums聽the聽votes聽per聽person聽and聽writes聽the聽totals聽to聽the<br />//聽report聽file<br /><br />//聽Precondition:<br />//聽聽聽聽聽votes[0..NUM_PRECINCTS-1][0..NUM_CANDIDATES]聽are聽assigned<br />//聽聽&&聽name[0..NUM_CANDIDATES-1]聽are聽assigned<br />//聽Postcondition:<br />//聽聽聽聽聽For聽each聽person聽i,聽name[i]聽has聽been聽output,<br />//聽聽聽聽聽followed聽by聽the聽sum<br />//聽聽聽聽聽votes[0][i]聽+聽votes[1][i]聽+聽聽+聽votes[NUM_PRECINCTS-1][i]<br /><br />{<br />聽聽聽聽int聽precinct;聽聽聽聽聽聽聽聽//聽Loop聽counter<br />聽聽聽聽int聽candidate;聽聽聽聽聽聽聽//聽Loop聽counter<br />聽聽聽聽int聽total;聽聽聽聽聽聽聽聽聽聽聽//聽Total聽votes聽for聽a聽candidate<br /><br />聽聽聽聽for聽(candidate聽=聽0;聽candidate聽<聽NUM_CANDIDATES;聽candidate++)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽Invariant聽(prior聽to聽test):<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽聽聽Votes聽for聽candidates聽0聽through聽(candidate-1)聽have<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽聽聽been聽summed聽and聽output<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽&&聽0聽<=聽candidate聽<=聽NUM_CANDIDATES<br /><br />聽聽聽聽聽聽聽聽total聽=聽0;<br /><br />聽聽聽聽聽聽聽聽//聽Compute聽column聽sum<br /><br />聽聽聽聽聽聽聽聽for聽(precinct聽=聽0;聽precinct聽<聽NUM_PRECINCTS;聽precinct++)<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Invariant聽(prior聽to聽test):<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽聽聽total聽==聽votes[0][candidate]聽+聽聽+<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽聽聽聽聽聽聽聽聽聽聽聽votes[precinct-1][candidate]<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽聽&&聽0聽<=聽precinct聽<=聽NUM_PRECINCTS<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽total聽=聽total聽+聽votes[precinct][candidate];<br /><br />聽聽聽聽聽聽聽聽reportFile聽<<聽Total聽votes聽for<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<<聽setw(10)聽<<聽name[candidate]聽<<聽:<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<<聽setw(3)聽<<聽total聽<<聽endl;<br /><br />聽聽聽聽}<br />聽聽聽聽reportFile聽<<聽endl;<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_737.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_738</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_739.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -