📄 page_542.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_542</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_541.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_542</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_543.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 542</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">聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽else<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽inPatient聽=聽REPTILE;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽C聽:聽inPatient聽=聽CAT;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽D聽:聽inPatient聽=聽DOG;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽B聽:聽if聽(ch2聽==聽i)<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽inPatient聽=聽BIRD;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽else<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽inPatient聽=聽BOVINE;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽H聽:聽inPatient聽=聽HORSE;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽default聽:聽inPatient聽=聽SHEEP;<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">Enumeration type values cannot be printed directly either. Printing is done by using a Switch statement that prints a character string corresponding to the value.</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">switch聽(inPatient)<br />{<br />聽聽聽聽case聽RODENT聽聽:聽cout聽<聽Rodent;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽CAT聽聽聽聽聽:聽cout聽<聽Cat;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽DOG聽聽聽聽聽:聽cout聽<聽Dog;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽BIRD聽聽聽聽:聽cout聽<聽Bird;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽REPTILE聽:聽cout聽<聽Reptile;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽HORSE聽聽聽:聽cout聽<聽Horse;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽BOVINE聽聽:聽cout聽<聽Bovine;<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽break;<br />聽聽聽聽case聽SHEEP聽聽聽:聽cout聽<聽Sheep;<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">You might ask, Why not use just a pair of letters or an integer number as a code to represent each animal in a program? We use enumeration types to make our programs more readable; they are another way to make code self-documenting.</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">Returning a Function Value</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">We have been using value-returning functions to compute and return values of built-in types such as </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">int</font><font face="Times New Roman, Times, Serif" size="3">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">float</font><font face="Times New Roman, Times, Serif" size="3">, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">char</font><font face="Times New Roman, Times, Serif" size="3">:</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_541.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_542</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_543.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -