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

📄 page_840.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_840</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_839.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_840</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_841.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 840</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">plementation details reduces complexity for the user and also shields the user from changes in the implementation.</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">Below is the specification of another ADT, one that might be useful for representing time in a 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="Times New Roman, Times, Serif" size="3">TYPE</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">TimeType</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">DOMAIN</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Each TimeType value is a time of day in the form of hours, minutes, and seconds.</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">OPERATIONS</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Set the time.</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Print the time.</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Increment the time by one second.</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Compare two times for equality.</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"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="29" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></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">Determine if one time is less than (comes before) another.</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 specification of an ADT defines abstract data values and abstract operations for the user. Ultimately, of course, the ADT must be implemented in program code. To implement an ADT, the programmer must do two things:</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">1. Choose a concrete data representation of the abstract data, using data types that already exist.</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">2. Implement each of the allowable operations in terms of program instructions.</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" width="100%"><tr><td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="96" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td>  <td colspan="3" height="12"></td>  <td rowspan="5"><img src="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" border="0" width="96" height="1" alt="3e26ecb1b6ac508ae10a0e39d2fb98b2.gif" /></td></tr><tr><td colspan="3" height="2"><table cellpadding="0" cellspacing="0" border="0"><tr><td></td></tr></table></td></tr><tr><td></td>  <td><font face="Times New Roman, Times, Serif" size="2">Data Representation The concrete form of data used to represent the abstract values of an abstract data type.</font></td><td></td></tr><tr><td colspan="3" height="2"><table cellpadding="0" cellspacing="0" border="0"><tr><td></td></tr></table></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">To implement the IntList ADT, we could choose a concrete data representation consisting of two items: a 100-element </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3"> array and an </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3"> variable that keeps track of the current length of the list. To implement the IntList operations, we must create algorithmssuch as the searching and sorting routines we wrote in Chapter 12based on the chosen data representation.</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">To implement the TimeType ADT, we might use three </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3"> variables for the data representationone for the hours, one for the minutes, and one for the seconds. Or we might use three strings (</font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">char</font><font face="Times New Roman, Times, Serif" size="3"> arrays) as the data representation, or even a three-element int array. The specification of the ADT does not confine us to any particular data representation. As long as we satisfy the specification, we are free to choose among alternative data representations and their associated algorithms. Our choice may be based on time efficiency (the speed at which the algorithms execute), space efficiency (the economical use of memory space), or simplicity and readability of the algorithms. Over time, you will acquire knowledge and experience that help you decide which implementation is best for a particular context.</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_839.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_840</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_841.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

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