亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? apa.htm

?? 21天學會VC的英文版
?? HTM
?? 第 1 頁 / 共 5 頁
字號:
24: 25: double  Area (double base, double height)    // Function definition26: {27: area = (0.5*base*height);28: return area;29: }</PRE><P>This program declares three variables, base, height, and area, on line 8. Variablesstore values that are used by the program. The type of a variable specifies the valuesto be stored in the variable. Table A.1 shows the various types supported by C++.</P><P><H4>TABLE A.1. VARIABLE DATA TYPES.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Variable Data Type</I></TD>		<TD ALIGN="LEFT"><I>Values</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned short int</TD>		<TD ALIGN="LEFT">0 to 65,535</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">short int</TD>		<TD ALIGN="LEFT">-32,768 to 32,767</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned long int</TD>		<TD ALIGN="LEFT">0 to 4,294,967,925</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">long int</TD>		<TD ALIGN="LEFT">-2,147,483,648 to 2,147,483,647</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">int</TD>		<TD ALIGN="LEFT">-2,147,483,648 to 2,147,483,647 (32 bit)</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">unsigned int</TD>		<TD ALIGN="LEFT">0 to 4,294,967,295 (32 bit)</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">char</TD>		<TD ALIGN="LEFT">256 character values</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">float</TD>		<TD ALIGN="LEFT">1.2e-38 to 3.4e38</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">double</TD>		<TD ALIGN="LEFT">2.2e-308 to 1.8e308</TD>	</TR></TABLE></P><P>To define a variable, you first define its type, followed by the name. You mayalso assign values to variables by using the assignment (=) operator, as in thesetwo examples:</P><P><PRE>double base = 5;unsigned long int base =5;</PRE><P>In C++, you may also define your own type definition. You do this by using thekeyword typedef, followed by the existing type and name:</P><P><PRE>typedef unsigned long int ULONG;ULONG base =5;</PRE><P>Defining your own type does save you the trouble of typing the entire declaration.</P><P>The next line of the code, line 9, defines the prototype of your function:</P><P><PRE>double Area (double,double);</PRE><P>This function has a type double, a name Area, and a parameter list of two variablesof type double. When you define the prototype, it is not necessary to define theparameters, but it is a good practice to do so. This program takes two inputs fromthe user, namely base and height of the triangle, and calculates the area of thetriangle. The base, height, and area are all variables. The Helloworld.cpp exampleused the insertion (&lt;&lt;) operator. In this example, you use the extraction (&gt;&gt;)operator. The program queries the user to enter a value for the height of the triangleon line 13. When the user enters a value for height, the data from the screen isextracted and placed into the variable height. The process is repeated for the baseof the triangle on lines 15 and 16. After accepting the input from the user, thefunction main() passes execution to the function Area(base,height) along with theparameter values for base and height. When main()<I> </I>passes the execution tothe function Area(base, height), it expects a value of type double in return fromthe function. The calculation of the area of the triangle is conducted on line 27:</P><P><PRE>area = (0.5*base*height);</PRE><BLOCKQUOTE>	<P><HR><STRONG>NOTE:</STRONG> Area is the name of a function, and area is a variable name.	Because C++ is case sensitive, it clearly distinguishes these two names. <HR></BLOCKQUOTE><P>This statement uses the standard operators, the assignment operator (=), and themultiplication operator (*). The assignment operator assigns the result of (0.5*base*height)to the variable area. The multiplication operator (*) calculates the resulting valuesof (0.5*base*height). The assignment operator (=) has an evaluation order from right-to-left.Hence, the multiplication is carried out prior to assigning the values to area. Thefive basic mathematical operators are addition (+), subtraction (-), multiplication(*), division (/), and modulus (%).</P><P>Line 28 of the Area function returns the value of the variable area to the main()function. At this point, the control of the program is returned to line 18 of themain() function. The remainder of the program displays the result of area to thescreen.</P><P><H3><A NAME="Heading3"></A>The if Statement, Operators, and Polymorphism</H3><PRE>While programming large complex programs, it is often necessary to query the user and provide direction to the program based on his input. This is accomplished by using the if statement. The next example demonstrates the application of an if statement. The format of the if statement is</PRE><PRE>if (<I>this expression</I>)   <I>do this</I>;</PRE><P>The if statement is often used in conjunction with relational operators. Anotherformat of the if statement is</P><P><PRE>if (<I>this expression</I>)   <I>do this</I>;else   <I>do this</I>;</PRE><P>Because if statements often use relational operators, let's review relationaloperators. Relational operators are used to determine if two expressions or numbersare equal. If the two expressions or numbers are not equal, the statement will evaluateto either 0 or false. Table A.2 lists the six relational operators defined in C++.</P><P><H4>TABLE A.2. RELATIONAL OPERATORS.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Operator</I></TD>		<TD ALIGN="LEFT"><I>Name</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">==</TD>		<TD ALIGN="LEFT">Comparative</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">!=</TD>		<TD ALIGN="LEFT">Not equal</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">&gt;</TD>		<TD ALIGN="LEFT">Greater than</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">&lt;</TD>		<TD ALIGN="LEFT">Less than</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">&gt;=</TD>		<TD ALIGN="LEFT">Greater than or equal to</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">&lt;=</TD>		<TD ALIGN="LEFT">Less than or equal to</TD>	</TR></TABLE></P><P>C++ also has logical operators. The advantage of logical operators is the abilityto compare two individual expressions and conclude whether they are true or false.Table A.3 lists the three logical operators.</P><P><H4>TABLE A.3. LOGICAL OPERATORS.</H4><P><TABLE BORDER="1">	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT"><I>Symbol</I></TD>		<TD ALIGN="LEFT"><I>Operator</I></TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">&amp;&amp;</TD>		<TD ALIGN="LEFT">AND</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">||</TD>		<TD ALIGN="LEFT">OR</TD>	</TR>	<TR ALIGN="LEFT" VALIGN="TOP">		<TD ALIGN="LEFT">!</TD>		<TD ALIGN="LEFT">NOT</TD>	</TR></TABLE></P><P>An important and powerful feature of C++ is function overloading, or polymorphism.<I>Polymorphism</I> is the ability to have more than one function with the same namethat differ in their parameter lists. The next example is an extension of the previoustriangle code. In this program, you will calculate the area of a triangle and a circle.You will be asked whether you want to calculate the area of a triangle or a circle.Depending upon your response, 1 for triangle and 2 for circle, the program collectsyour input and calculates the area. In Listing A.3, the Area function is overloaded.The same function name is used to calculate the area of the triangle or the circle.The functions differ only in their parameter lists.</P><P><H4>LISTING A.3. Overload.ccp.</H4><PRE> 1: // Workspace Name:  Overload 2: // Program Name:  Overload.cpp 3:  4: # include &lt;iostream.h&gt; 5:  6: double  base,height,radius;        // Global variables 7: double  Area_of_triangle,Area_of_circle;  // Global variables 8: int  choice;                // Global variable 9: 10: double  Area (double,double);       // Function prototype11: double  Area (double);           // Function prototype12: 13: const double  pi = 3.14;          // Constant variable14: 15: void main()                 // main function16: 17: {18:   cout &lt;&lt; &quot;To find the area of a Triangle, input 1 \n&quot;;19:   cout &lt;&lt; &quot;To find the area of a Circle, input 2 \n&quot;;20:   cin &gt;&gt; choice;21: 22: if (choice == 1)23: </PRE><PRE>24: {</PRE><PRE>25:   cout &lt;&lt; &quot;Enter the base of the triangle: &quot;;26:   cin &gt;&gt; base;27:   cout &lt;&lt; &quot;Enter the height of the triangle: &quot;;28:   cin &gt;&gt; height;29: 30: Area_of_triangle = Area(base,height);31: 32:   cout &lt;&lt; &quot;The Area of the Triangle is: &quot;&lt;&lt;Area_of_triangle&lt;&lt;endl;33: }34: 35: if (choice == 2)36: 37: {38:   cout &lt;&lt; &quot;Enter radius of the Circle: &quot;;39:   cin &gt;&gt; radius;40:   Area_of_circle = Area(radius);41:   cout &lt;&lt; &quot;The area of the Circle is: &quot;&lt;&lt;Area_of_circle&lt;&lt;endl;42: }43: 44: if (choice != 1 &amp;&amp; choice != 2)45: 46: {47:   cout &lt;&lt; &quot;Sorry! You must enter either 1 or 2 \n&quot;;48: }49: }50: 51: double Area (double base, double height)52: {53:   return (0.5*base*height)54: }55: 56: double Area(double radius)57: {58:   return (pi*radius*radius);59: }</PRE><H3><A NAME="Heading4"></A>Global and Local Variables</H3><P>In all of the preceding examples, the variables have been declared at the beginningof the program, prior to defining the main() function. Declaring variables in thisfashion is more akin to C programs than C++. They are global variables and can beaccessed by all the functions. However, you may also define local variables thathave a scope only in a particular function. Local variables can have the same namesas the global variables, but they do not change the global variables. Local variablesrefer only to the function in which they are defined. This difference can be confusingand lead to erratic results.</P><P>The program in Listing A.4 clearly shows the difference between global and localvariables. You will calculate the area of a circle using global variables and localvariables.</P><P><H4>LISTING A.4. Global.cpp.</H4><PRE> 1: // Workspace:  Variable 2: // Program name:  Global.cpp 3:  4: #include &lt;iostream.h&gt; 5:  6: double  area; 7: double Area (double); 8: const double pi = 3.14; 9: double  radius = 5;10: 11: int main()12: 13: {14: cout&lt;&lt;&quot;This Program Calculates The Area Of A Circle \n&quot;;15: area = Area (radius);16: cout &lt;&lt; &quot;The Area of the Circle is: &quot;&lt;&lt;area&lt;&lt;endl;17: cout &lt;&lt; &quot;The Radius In the Main() Function is: &quot;&lt;&lt;radius&lt;&lt;endl;18: return 0;19: }20: 21: double  Area (double radius)22: {23: area = (pi*radius*radius);24: cout&lt;&lt;&quot;The Radius In the Area() Function is: &quot;&lt;&lt;radius&lt;&lt;endl;25: return area;26: }</PRE><P>The variable radius is accessible in the main() function and also the Area() function,and it is the same. The result of executing this program is shown in Figure A.6.</P><P><A HREF="javascript:popUp('0afig06.gif')"><B>FIGURE A.6.</B></A><B> </B><I>Global.cpp--usinga global variable.</I></P><P>As the program executes, it shows the value of the variable radius in the differentfunctions. You will now modify the global variable to be a local variable. Add anadditional line to the Area function defining a local variable:</P><P><PRE>double radius = 2;</PRE><P>Compile and execute this program. The results are shown in Figure A.7.</P><P><A HREF="javascript:popUp('0afig07.gif')"><B>FIGURE A.7.</B></A><B> </B><I>Global.cpp--globaland local variables.</I></P><P>You will notice that the value of the variable radius remains unchanged in themain() function and changes locally in the Area() function. The area of the circleis calculated based on the value of the local variable, whereas at the same time,the value of the global variable is not changed but is hidden from the function Area().</P><BLOCKQUOTE>	<P><HR>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆国产精品久久| 国产日韩亚洲欧美综合| 亚洲一区中文日韩| 99国产精品99久久久久久| 国产欧美日韩三级| 国产毛片精品国产一区二区三区| 精品国产一区二区国模嫣然| 久久国产三级精品| 日韩美女一区二区三区四区| 91网站在线观看视频| 国产精品久久久99| 91视频91自| 综合久久给合久久狠狠狠97色| 成人精品一区二区三区中文字幕| 日韩一区二区精品在线观看| 亚洲黄色性网站| 欧美色图一区二区三区| 一区二区三区日本| 91亚洲精品久久久蜜桃网站 | 99久久久久久| 亚洲精品在线观看视频| 久久99久久久欧美国产| 久久精品视频网| 丁香婷婷综合五月| 欧美一区二区网站| 亚洲美女精品一区| 中文字幕不卡在线| 亚洲韩国一区二区三区| 久久91精品国产91久久小草 | 一区在线播放视频| 国产日韩影视精品| 国产精品久久久久久久久图文区| 国产日产欧美一区| 亚洲同性gay激情无套| 日本成人在线网站| 久久国产日韩欧美精品| 日本韩国欧美在线| 欧美一级电影网站| 亚洲精品综合在线| 欧美日韩五月天| 国产精品久久久久一区| 一级精品视频在线观看宜春院| 精品国产一区二区三区忘忧草 | 中文字幕一区二区三区在线不卡| 欧美无人高清视频在线观看| 国产亚洲精品福利| 色婷婷精品大视频在线蜜桃视频 | 一区二区在线看| 日韩一级成人av| 91精品1区2区| 极品少妇xxxx精品少妇偷拍| 欧美国产日韩一二三区| 欧美肥妇bbw| 99久久免费视频.com| 青青草91视频| 亚洲欧洲av另类| 精品国产一区二区亚洲人成毛片 | xf在线a精品一区二区视频网站| 久久成人免费网| 亚洲视频 欧洲视频| 在线综合+亚洲+欧美中文字幕| 蜜臀精品一区二区三区在线观看 | 国产传媒欧美日韩成人| 亚洲成人自拍偷拍| 中文字幕亚洲不卡| 欧美福利视频一区| 在线日韩一区二区| 成人免费av资源| 经典三级视频一区| 水蜜桃久久夜色精品一区的特点| 欧美一级视频精品观看| 色综合咪咪久久| 成人av综合一区| 美女在线视频一区| 一区二区免费视频| 国产精品福利影院| 久久日韩精品一区二区五区| 欧美亚洲愉拍一区二区| 成人免费看片app下载| 国产高清无密码一区二区三区| 国产原创一区二区| 欧美激情在线观看视频免费| 91麻豆精品国产| 欧美午夜免费电影| 国产一区 二区 三区一级| 亚瑟在线精品视频| 亚洲成人手机在线| 亚洲欧美国产三级| 久久久久久久久久电影| 亚洲精品一区二区三区蜜桃下载| 日本道色综合久久| 91在线精品一区二区| 成人自拍视频在线| 视频一区在线播放| 日韩av在线免费观看不卡| 天堂一区二区在线免费观看| 亚洲不卡av一区二区三区| 夜夜精品视频一区二区| 亚洲国产精品久久一线不卡| 亚洲国产精品一区二区久久| 亚洲成av人片www| 国产精品一区二区免费不卡 | 亚洲成人中文在线| 亚洲va欧美va人人爽| 亚洲成年人网站在线观看| 亚洲国产精品自拍| 日韩国产欧美在线视频| 午夜精品国产更新| 一区二区三区日韩欧美| 亚洲成av人片一区二区三区| 蜜臀av性久久久久蜜臀aⅴ流畅| 美女视频黄a大片欧美| 捆绑变态av一区二区三区| 久久99国产精品麻豆| 国产91精品精华液一区二区三区| eeuss鲁一区二区三区| 91黄色免费观看| 欧美欧美欧美欧美| 日韩欧美成人一区二区| 国产精品毛片大码女人| 亚洲欧美日韩国产中文在线| 亚洲精品国产a久久久久久| 午夜伊人狠狠久久| 国产剧情av麻豆香蕉精品| av中文字幕在线不卡| 欧美精品一二三| 久久你懂得1024| 一区二区欧美精品| 狠狠色综合播放一区二区| 久久亚洲一区二区三区明星换脸| 久久蜜桃av一区精品变态类天堂 | 色偷偷88欧美精品久久久| 在线电影院国产精品| 国产欧美日产一区| 亚洲亚洲人成综合网络| 国产在线视视频有精品| 99久久久国产精品| 欧美乱妇23p| 欧美一激情一区二区三区| 国产午夜精品一区二区三区嫩草| 久久久三级国产网站| 在线不卡中文字幕播放| 日本一区二区三区四区| 午夜国产不卡在线观看视频| 国产精品一区二区x88av| 在线观看欧美黄色| 欧美激情一区二区三区| 丝袜美腿高跟呻吟高潮一区| 国产91丝袜在线18| 欧美一级国产精品| 亚洲女同一区二区| 国产精品一区二区三区乱码| 精品视频在线看| 国产精品区一区二区三区| 秋霞午夜鲁丝一区二区老狼| 91丝袜国产在线播放| 亚洲视频电影在线| 国产成人免费xxxxxxxx| 日韩欧美不卡在线观看视频| 亚洲国产三级在线| 99国产麻豆精品| 国产网红主播福利一区二区| 美女尤物国产一区| 欧美日韩综合在线免费观看| 中文字幕一区在线| 成人a区在线观看| 久久天堂av综合合色蜜桃网| 奇米精品一区二区三区在线观看一| 成人激情黄色小说| 国产三级欧美三级日产三级99| 国产一区二区不卡在线| 欧美一区二区视频观看视频| 国产精品夜夜嗨| 亚洲婷婷在线视频| 欧美系列亚洲系列| 亚洲摸摸操操av| 26uuu亚洲综合色| 91在线无精精品入口| 亚洲一区二区欧美激情| 日韩欧美久久一区| 99久久精品免费观看| 青青国产91久久久久久| 日韩欧美一级二级三级久久久| 国产麻豆精品在线观看| 亚洲天堂a在线| 欧美成人高清电影在线| 在线观看免费一区| 国产91丝袜在线观看| 国产精品18久久久久久久久 | 亚洲无人区一区| 日韩高清中文字幕一区| 九九视频精品免费| 中文字幕巨乱亚洲| 欧美一区二区三区思思人| 99久久伊人精品| 99国产精品视频免费观看| 国产成人久久精品77777最新版本| 欧美视频中文字幕| 免费高清成人在线| 91精品国产免费|