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

📄 page_719.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_719</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_718.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_719</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_720.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 719</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">#include聽&lt;iomanip.h&gt;聽聽聽聽//聽For聽setw()<br />聽聽.<br />聽聽.<br />聽聽.<br /><br />for聽(row聽=聽0;聽row聽&lt;聽NUM_ROWS;聽row++)<br />{<br />聽聽聽聽聽聽聽聽//聽Invariant聽(prior聽to聽test):<br />聽聽聽聽聽聽聽聽//聽聽聽聽聽Rows聽0聽through聽row-1聽of聽table聽have聽been聽output<br />聽聽聽聽聽聽聽聽//聽聽&amp;&amp;聽&lt;=聽row聽&lt;=聽NUM_ROWS<br /><br />聽聽聽聽for聽(col聽=聽0;聽col聽&lt;聽NUM_COLS;聽col++)<br /><br />聽聽聽聽聽聽聽聽聽聽聽聽//聽聽Invariant聽(prior聽to聽test):<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽聽聽聽table[row][0..col-1]聽have聽been聽output<br />聽聽聽聽聽聽聽聽聽聽聽聽//聽聽聽&amp;&amp;聽0聽&lt;=聽col聽&lt;=聽NUM_COLS<br /><br />聽聽聽聽聽聽聽聽cout聽&lt;&lt;聽setw(15)聽&lt;&lt;聽table[row][col];<br />聽聽聽聽cout聽&lt;&lt;聽endl;<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">This code fragment prints the values of the table in columns that are 15 characters wide. As a matter of proper style, this fragment should be preceded by code that prints headings over the columns to identify their contents.</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">There's no rule that we have to print each row on a line. We could turn the table sideways and print each column on one line simply by exchanging the two For loops. When you are printing a table, you must consider which order of presentation makes the most sense and how the table fits on the page. For example, a table with 6 columns and 100 rows would be best printed as 6 columns, 100 lines long.</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">Almost all processing of data stored in a two-dimensional array involves either processing by row or processing by column. In most of our examples the index type has been </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3">, but the pattern of operation of the loops is the same no matter what types the indices are.</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 looping patterns for row processing and column processing are so useful that they are summarized below. To make them more general, we use </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">minRow</font><font face="Times New Roman, Times, Serif" size="3"> for the first row number and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">minCol</font><font face="Times New Roman, Times, Serif" size="3"> for the first column number. Remember that row processing has the row index in the outer loop, and column processing has the column index in the outer loop.</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"><i>Row Processing</i></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">for聽(row聽=聽minRow;聽row聽&lt;聽rowLength;聽row++)<br />聽聽聽聽for聽(col聽=聽minCol;聽col聽&lt;聽colLength;聽col++)<br />聽聽聽聽聽聽聽聽.<br />聽聽聽聽聽聽聽聽.<br />聽聽聽聽聽聽聽聽.聽聽聽聽聽聽聽聽聽聽//聽Whatever聽processing聽is聽required</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_718.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_719</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_720.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

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