📄 page_587.html
字号:
<td><font face="Times New Roman, Times, Serif" size="3"> Prints </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">Ace</font><font face="Times New Roman, Times, Serif" size="3"> (including the double quotes)</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">3. Write a While loop that copies all the characters (including whitespace characters) from an input file </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">inFile</font><font face="Times New Roman, Times, Serif" size="3"> to an output file </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">outFile</font><font face="Times New Roman, Times, Serif" size="3">, except that every lowercase letter is converted to uppercase. Assume that both files have been opened successfully before the loop begins. The loop should terminate when end-of-file is detected.</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">4. Given the following declarations</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="24" 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="Courier New, Courier, Mono New, Courier, Mono" size="2">int聽n;<br />char聽ch1;<br />char聽ch2;</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">and given that n contains a two-digit number, translate n into two single characters where </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">ch1</font><font face="Times New Roman, Times, Serif" size="3"> holds the higher-order digit, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">ch2</font><font face="Times New Roman, Times, Serif" size="3"> holds the lower-order digit. For example, if </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">n聽=</font><font face="Times New Roman, Times, Serif" size="3"> 59, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">ch1</font><font face="Times New Roman, Times, Serif" size="3"> would equal 5, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">ch2</font><font face="Times New Roman, Times, Serif" size="3"> would equal 9. Then output the two digits as characters in the same order as the original numbers. (<i>Hint:</i> Consider how you might use the </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">/</font><font face="Times New Roman, Times, Serif" size="3"> and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">%</font><font face="Times New Roman, Times, Serif" size="3"> operators in your solution.)</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">5. In a program you are writing, a </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">float</font><font face="Times New Roman, Times, Serif" size="3"> variable </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">beta</font><font face="Times New Roman, Times, Serif" size="3"> may potentially contain a very large number. Before multiplying </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">beta</font><font face="Times New Roman, Times, Serif" size="3"> by 100.0, you want the program to test whether it is safe to do so. Write an If statement that tests for a possible overflow <i>before</i> multiplying by 100.0. Specifically, if the multiplication would lead to overflow, print a message and don't perform the multiplication; otherwise, go ahead with the multiplication.</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">6. Declare an enumeration type for the course numbers of computer courses at your school.</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">7. Declare an enumeration type for the South American countries.</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">8. Declare an enumeration type for the work days of the week (Monday through Friday).</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">9. Write a value-returning function that converts the first two letters of a work day into the type declared in Exercise 8.</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">10. Write a void function that prints a value of the type declared in Exercise 8.</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_586.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_587</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_588.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -