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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? ch07.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
<!-- This document was created from RTF source by rtftohtml version 3.0.1 -->

	<META NAME="GENERATOR" Content="Symantec Visual Page 1.0">
	<META HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">
	<TITLE>Teach Yourself C++ in 21 Days</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<H1 ALIGN="CENTER"><A HREF="ch06.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch06.htm"><IMG SRC="../buttons/BLANPREV.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANPREV.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="javascript:if(confirm('http://www.mcp.com/sams  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.mcp.com/sams'" tppabs="http://www.mcp.com/sams"><IMG
SRC="../buttons/BLANHOME.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANHOME.GIF" WIDTH="37" HEIGHT="37" ALIGN="BOTTOM"
BORDER="0"></A><A HREF="../index.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/index.htm"><IMG SRC="../buttons/BLANTOC.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANTOC.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A><A HREF="ch07rv1.htm" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/htm/ch07rv1.htm"><IMG SRC="../buttons/BLANNEXT.GIF" tppabs="http://petunia.atomki.hu/pio/Manuals/english/0-672/0-672-31070-8/buttons/BLANNEXT.GIF"
WIDTH="37" HEIGHT="37" ALIGN="BOTTOM" BORDER="0"></A></H1>
<H1></H1>

<UL>
	<LI><A HREF="#Heading1">Day 7</A>
	<UL>
		<LI><A HREF="#Heading2">More Program Flow</A>
		<UL>
			<LI><A HREF="#Heading3">Looping</A>
			<UL>
				<LI><A HREF="#Heading4">The Roots of Looping goto</A>
			</UL>
			<LI><A HREF="#Heading5">Listing 7.1. Looping with the keyword goto</A><A HREF="#Heading6">.</A>
			<UL>
				<LI><A HREF="#Heading7">Why goto Is Shunned</A>
			</UL>
			<LI><A HREF="#Heading8">The goto Statement</A>
			<LI><A HREF="#Heading9">while Loops</A>
			<LI><A HREF="#Heading10">Listing 7.2. while loops</A><A HREF="#Heading11">.</A>
			<LI><A HREF="#Heading12">The while Statement</A>
			<UL>
				<LI><A HREF="#Heading13">More Complicated while Statements</A>
			</UL>
			<LI><A HREF="#Heading14">Listing 7.3. Complex while loops</A><A HREF="#Heading15">.</A>
			<UL>
				<LI><A HREF="#Heading16">continue and break</A>
			</UL>
			<LI><A HREF="#Heading17">Listing 7.4. break and continue</A><A HREF="#Heading18">.</A>
			<LI><A HREF="#Heading19">The continue Statement</A>
			<LI><A HREF="#Heading20">The break Statement</A>
			<UL>
				<LI><A HREF="#Heading21">while (1) Loops</A>
			</UL>
			<LI><A HREF="#Heading22">Listing 7.5. while (1) loops</A><A HREF="#Heading23">.</A>
			<LI><A HREF="#Heading24">do...while Loops</A>
			<LI><A HREF="#Heading25">Listing 7.6. Skipping the body of the while Loop</A><A HREF="#Heading26">.</A>
			<LI><A HREF="#Heading27">do...while</A>
			<LI><A HREF="#Heading28">Listing 7.7. Demonstrates do...while loop</A><A HREF="#Heading29">.</A>
			<LI><A HREF="#Heading30">The do...while Statement</A>
			<LI><A HREF="#Heading31">for Loops</A>
			<LI><A HREF="#Heading32">Listing 7.8. While reexamined</A><A HREF="#Heading33">.</A>
			<LI><A HREF="#Heading34">Listing 7.9. Demonstrating the for loop</A><A HREF="#Heading35">.</A>
			<LI><A HREF="#Heading36">The for Statement</A>
			<UL>
				<LI><A HREF="#Heading37">Advanced for Loops</A>
			</UL>
			<LI><A HREF="#Heading38">Listing 7.10. Demonstrating multiple statements in for loops</A><A
			HREF="#Heading39">.</A>
			<LI><A HREF="#Heading40">Listing 7.11. Null statements in for loops</A><A HREF="#Heading41">.</A>
			<LI><A HREF="#Heading42">Listing 7.12. Illustrating empty for loop statement</A><A
			HREF="#Heading43">.</A>
			<UL>
				<LI><A HREF="#Heading44">Empty for Loops</A>
			</UL>
			<LI><A HREF="#Heading45">Listing 7.13. Illustrates the null statement in a for loop</A><A
			HREF="#Heading46">.</A>
			<UL>
				<LI><A HREF="#Heading47">Nested Loops</A>
			</UL>
			<LI><A HREF="#Heading48">Listing 7.14. Illustrates nested for loops</A><A HREF="#Heading49">.</A>
			<UL>
				<LI><A HREF="#Heading50">Scoping in for Loops</A>
			</UL>
			<LI><A HREF="#Heading51">Summing Up Loops</A>
			<LI><A HREF="#Heading52">Listing 7.15. Solving the nth Fibonacci number</A>
			<LI><A HREF="#Heading53">using iteration.</A>
			<LI><A HREF="#Heading54">switch Statements</A>
			<LI><A HREF="#Heading55">Listing 7.16. Demonstrating the switch statement</A><A HREF="#Heading56">.</A>
			<LI><A HREF="#Heading57">The switch Statement</A>
			<UL>
				<LI><A HREF="#Heading58">Using a switch Statement with a Menu</A>
			</UL>
			<LI><A HREF="#Heading59">Listing 7.17. Demonstrating a forever loop</A><A HREF="#Heading60">.</A>
			<LI><A HREF="#Heading61">Summary</A>
			<LI><A HREF="#Heading62">Q&amp;A</A>
			<LI><A HREF="#Heading63">Workshop</A>
			<UL>
				<LI><A HREF="#Heading64">Quiz</A>
				<LI><A HREF="#Heading65">Exercises</A>
			</UL>
		</UL>
	</UL>
</UL>

<P>
<HR SIZE="4">

<H2 ALIGN="CENTER"><BR>
<A NAME="Heading1"></A><FONT COLOR="#000077">Day 7</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2"></A><FONT COLOR="#000077">More Program Flow</FONT></H2>
<P>Programs accomplish most of their work by branching and looping. On Day 4, &quot;Expressions
and Statements,&quot; you learned how to branch your program using the <TT>if</TT>
statement. Today you learn

<UL>
	<LI>What loops are and how they are used.
	<P>
	<LI>How to build various loops.
	<P>
	<LI>An alternative to deeply-nested <TT>if/else</TT> statements.
</UL>

<H3 ALIGN="CENTER"><A NAME="Heading3"></A><FONT COLOR="#000077">Looping</FONT></H3>
<P>Many programming problems are solved by repeatedly acting on the same data. There
are two ways to do this: recursion (discussed yesterday) and iteration. Iteration
means doing the same thing again and again. The principal method of iteration is
the loop.
<H4 ALIGN="CENTER"><A NAME="Heading4"></A><FONT COLOR="#000077">The Roots of Looping
goto</FONT></H4>
<P>In the primitive days of early computer science, programs were nasty, brutish,
and short. Loops consisted of a label, some statements, and a jump.</P>
<P>In C++, a label is just a name followed by a colon (<TT>:</TT>). The label is
placed to the left of a legal C++ statement, and a jump is accomplished by writing
<TT>goto</TT> followed by the label name. Listing 7.1 illustrates this.</P>
<P><A NAME="Heading5"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 7.1. Looping
with the keyword goto.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:    // Listing 7.1
2:    // Looping with goto
3:
4:    #include &lt;iostream.h&gt;
5:
6:    int main()
7:    {
8:           int counter = 0;      // initialize counter
9:    loop:  counter ++;           // top of the loop
10:            cout &lt;&lt; &quot;counter: &quot; &lt;&lt; counter &lt;&lt; &quot;\n&quot;;
11:           if (counter &lt; 5)            // test the value
12:               goto loop;                 // jump to the top
13:
14:           cout &lt;&lt; &quot;Complete. Counter: &quot; &lt;&lt; counter &lt;&lt; &quot;.\n&quot;;
15:       return 0;
<TT>16: }</TT>
Output: counter: 1
counter: 2
counter: 3
counter: 4
counter: 5
Complete. Counter: 5.
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis:</B></FONT><B> </B>On line 8, <TT>counter</TT>
is initialized to <TT>0</TT>. The label <TT>loop</TT> is on line 9, marking the top
of the loop. <TT>Counter</TT> is incremented and its new value is printed. The value
of <TT>counter</TT> is tested on line 11. If it is less than 5, the <TT>if</TT> statement
is true and the <TT>goto</TT> statement is executed. This causes program execution
to jump back to line 9. The program continues looping until <TT>counter</TT> is equal
to 5, at which time it &quot;falls through&quot; the loop and the final output is
printed.
<H4 ALIGN="CENTER"><A NAME="Heading7"></A><FONT COLOR="#000077">Why goto Is Shunned</FONT></H4>
<P><TT>goto</TT> has received some rotten press lately, and it's well deserved. <TT>goto</TT>
statements can cause a jump to any location in your source code, backward or forward.
The indiscriminate use of <TT>goto</TT> statements has caused tangled, miserable,
impossible-to-read programs known as &quot;spaghetti code.&quot; Because of this,
computer science teachers have spent the past 20 years drumming one lesson into the
heads of their students: &quot;Never, ever, ever use <TT>goto</TT>! It is evil!&quot;</P>
<P>To avoid the use of <TT>goto</TT>, more sophisticated, tightly controlled looping
commands have been introduced: <TT>for</TT>, <TT>while</TT>, and <TT>do...while</TT>.
Using these makes programs that are more easily understood, and <TT>goto</TT> is
generally avoided, but one might argue that the case has been a bit overstated. Like
any tool, carefully used and in the right hands, <TT>goto</TT> can be a useful construct,
and the ANSI committee decided to keep it in the language because it has its legitimate
uses. But as they say, kids, don't try this at home.
<H3 ALIGN="CENTER"><A NAME="Heading8"></A><FONT COLOR="#000077">The goto Statement</FONT></H3>
<P>To use the <TT>goto</TT> statement, you write <TT>goto</TT> followed by a label
name. This causes an unconditioned jump to the label. Example</P>
<PRE><FONT COLOR="#0066FF">if (value &gt; 10)     goto end;if (value &lt; 10)     goto end;cout &lt;&lt; &quot;value is &#194;10!&quot;;end:cout &lt;&lt; &quot;done&quot;;
</FONT></PRE>


<BLOCKQUOTE>
	<P>
<HR>
<FONT COLOR="#000077"><B>WARNING:</B></FONT><B> </B>Use of <TT>goto</TT> is almost
	always a sign of bad design. The best advice is to avoid using it. In 10 years of
	programming, I've needed it only once. 
<HR>


</BLOCKQUOTE>

<H3 ALIGN="CENTER"><A NAME="Heading9"></A><FONT COLOR="#000077">while Loops</FONT></H3>
<P>A <TT>while</TT> loop causes your program to repeat a sequence of statements as
long as the starting condition remains true. In the example of <TT>goto</TT>, in
Listing 7.1, the counter was incremented until it was equal to 5. Listing 7.2 shows
the same program rewritten to take advantage of a <TT>while</TT> loop.</P>
<P><A NAME="Heading10"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 7.2. while loops.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:    // Listing 7.2
2:    // Looping with while
3:
4:    #include &lt;iostream.h&gt;
5:
6:    int main()
7:    {
8:      int counter = 0;               // initialize the condition
9:
10:      while(counter &lt; 5)     // test condition still true
11:       {
12:          counter++;              // body of the loop
13:          cout &lt;&lt; &quot;counter: &quot; &lt;&lt; counter &lt;&lt; &quot;\n&quot;;
14:      }
15:
16:      cout &lt;&lt; &quot;Complete. Counter: &quot; &lt;&lt; counter &lt;&lt; &quot;.\n&quot;;
17:       return 0;
<TT>18: }</TT>
Output: counter: 1
counter: 2
counter: 3
counter: 4
counter: 5
Complete. Counter: 5.
</FONT></PRE>
<P><FONT COLOR="#000077"><B>Analysis:</B></FONT><B> </B>This simple program demonstrates
the fundamentals of the <TT>while</TT> loop. A condition is tested, and if it is
true, the body of the <TT>while</TT> loop is executed. In this case, the condition
tested on line 10 is whether <TT>counter</TT> is less than 5. If the condition is
true, the body of the loop is executed; on line 12 the counter is incremented, and
on line 13 the value is printed. When the conditional statement on line 10 fails
(when <TT>counter</TT> is no longer less than 5), the entire body of the <TT>while</TT>
loop (lines 11-14) is skipped. Program execution falls through to line 15.
<H3 ALIGN="CENTER"><A NAME="Heading12"></A><FONT COLOR="#000077">The while Statement</FONT></H3>
<P>The syntax for the <TT>while</TT> statement is as follows:</P>
<PRE><FONT COLOR="#0066FF">while ( condition )
statement;
</FONT></PRE>
<P>condition is any C++ expression, and statement is any valid C++ statement or block
of statements. When condition evaluates to <TT>TRUE</TT> (<TT>1</TT>), statement
is executed, and then condition is tested again. This continues until condition tests
<TT>FALSE</TT>, at which time the <TT>while</TT> loop terminates and execution continues
on the first line below statement.<BR>
<BR>
Example</P>
<PRE><FONT COLOR="#0066FF">// count to 10
int x = 0;
while (x &lt; 10)
cout &lt;&lt; &quot;X: &quot; &lt;&lt; x++;
</FONT></PRE>
<H4 ALIGN="CENTER"><A NAME="Heading13"></A><FONT COLOR="#000077">More Complicated
while Statements</FONT></H4>
<P>The condition tested by a <TT>while</TT> loop can be as complex as any legal C++
expression. This can include expressions produced using the logical <TT>&amp;&amp;</TT>
(AND), <TT>||</TT> (OR), and <TT>!</TT> (NOT) operators. Listing 7.3 is a somewhat
more complicated <TT>while</TT> statement.</P>
<P><A NAME="Heading14"></A><FONT SIZE="4" COLOR="#000077"><B>Listing 7.3. Complex
while loops.</B></FONT></P>
<PRE><FONT COLOR="#0066FF">1:    // Listing 7.3
2:    // Complex while statements
3:
4:    #include &lt;iostream.h&gt;
5:
6:    int main()
7:    {
8:      unsigned short small;
9:      unsigned long  large;
10:      const unsigned short MAXSMALL=65535;
11:
12:      cout &lt;&lt; &quot;Enter a small number: &quot;;
13:      cin &gt;&gt; small;
14:      cout &lt;&lt; &quot;Enter a large number: &quot;;
15:      cin &gt;&gt; large;
16:
17:       cout &lt;&lt; &quot;small: &quot; &lt;&lt; small &lt;&lt; &quot;...&quot;;
18:
19:      // for each iteration, test three conditions
20:      while (small &lt; large &amp;&amp; large &gt; 0 &amp;&amp; small &lt; MAXSMALL)
21:
22:      {
23:         if (small % 5000 == 0)  // write a dot every 5k lines
24:           cout &lt;&lt; &quot;.&quot;;
25:
26:         small++;
27:
28:         large-=2;
29:      }
30:
31:      cout &lt;&lt; &quot;\nSmall: &quot; &lt;&lt; small &lt;&lt; &quot; Large: &quot; &lt;&lt; large &lt;&lt; endl;
32:     return 0;
<TT>33: }</TT>
Output: Enter a small number: 2

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文字幕综合网| 伦理电影国产精品| 中文字幕av一区二区三区| 91精品国模一区二区三区| 欧美日本国产一区| 欧美丰满嫩嫩电影| 欧美疯狂性受xxxxx喷水图片| 欧美三级蜜桃2在线观看| 欧美日韩在线观看一区二区| 欧洲精品视频在线观看| 欧美亚洲国产一区二区三区| 欧美在线免费观看视频| 欧美日韩一区在线观看| 欧美日韩一区精品| 69堂精品视频| 日韩女同互慰一区二区| 26uuu精品一区二区三区四区在线| 精品久久久久久久久久久久包黑料 | 一区二区三区在线免费播放 | 激情五月播播久久久精品| 国产尤物一区二区在线| 国产成人av电影在线播放| www.亚洲色图.com| 日本精品一区二区三区高清| 91国偷自产一区二区三区观看 | 911精品国产一区二区在线| 在线综合视频播放| 精品久久久久久综合日本欧美| 久久亚洲精品国产精品紫薇| 国产精品丝袜91| 一区二区三区精品在线| 日韩高清一区二区| 国产精品影视天天线| 99精品视频一区二区| 欧美特级限制片免费在线观看| 欧美一级电影网站| 国产精品你懂的| 性感美女久久精品| 国产麻豆午夜三级精品| 99视频精品免费视频| 欧美日韩1234| 久久精品一级爱片| 亚洲成人免费视| 国产一区二区伦理| 在线免费亚洲电影| 久久一区二区视频| 一区二区高清免费观看影视大全| 日本不卡在线视频| 国产成人精品一区二区三区四区| 日本二三区不卡| 精品国产亚洲一区二区三区在线观看 | 久久婷婷国产综合国色天香| 亚洲欧美日韩国产中文在线| 玖玖九九国产精品| 色综合久久88色综合天天免费| 日韩欧美国产综合| 亚洲精品国产成人久久av盗摄 | 亚洲一区二区不卡免费| 国产综合一区二区| 欧美午夜一区二区| 日本一区二区三区免费乱视频 | 成年人网站91| 制服丝袜中文字幕亚洲| 中文字幕一区视频| 久久草av在线| 欧美色图在线观看| 国产精品拍天天在线| 蜜臀av性久久久久蜜臀av麻豆| www.性欧美| 精品粉嫩aⅴ一区二区三区四区| 亚洲一区二区三区在线看| 国产一区二区剧情av在线| 欧美日本一区二区| 亚洲精品综合在线| 国产一区二区在线电影| 宅男在线国产精品| 亚洲一区二区三区在线| 99久久精品国产导航| 精品成人一区二区三区四区| 五月婷婷综合激情| 91福利在线观看| 中文字幕在线播放不卡一区| 国产在线播放一区| 欧美大片顶级少妇| 日本麻豆一区二区三区视频| 99视频热这里只有精品免费| 久久精品视频在线看| 麻豆成人av在线| 91精品一区二区三区在线观看| 亚洲精品成人天堂一二三| 成人a级免费电影| 久久精品一区蜜桃臀影院| 欧美日韩视频在线第一区 | 精品国产伦一区二区三区免费 | fc2成人免费人成在线观看播放| 中文字幕第一区二区| 青草av.久久免费一区| 欧美日韩视频第一区| 一区二区三区精密机械公司| 97久久超碰国产精品| 国产精品蜜臀av| 成人福利视频在线| 国产精品乱码妇女bbbb| 丁香婷婷综合色啪| 国产精品丝袜91| 99riav久久精品riav| 综合激情成人伊人| 99久久婷婷国产| 亚洲欧美精品午睡沙发| 91视频一区二区三区| 亚洲欧美色图小说| 在线免费视频一区二区| 亚洲国产成人高清精品| 欧美日本一区二区在线观看| 日韩成人免费电影| 日韩女优av电影| 国产成人啪午夜精品网站男同| 国产欧美1区2区3区| 99久久国产免费看| 一区二区三区中文在线观看| 在线观看视频欧美| 无码av中文一区二区三区桃花岛| 91.com在线观看| 狠狠色2019综合网| 欧美高清在线一区| 91黄色在线观看| 五月婷婷激情综合网| 欧洲精品一区二区三区在线观看| 亚洲一二三级电影| 7777女厕盗摄久久久| 蓝色福利精品导航| 中文字幕乱码亚洲精品一区| 色综合夜色一区| 日韩经典中文字幕一区| 2021国产精品久久精品| www.亚洲人| 亚洲国产你懂的| 精品国产自在久精品国产| 国产69精品久久99不卡| 亚洲香肠在线观看| 精品国产免费一区二区三区四区| 成人午夜免费电影| 亚洲一区在线免费观看| 日韩一级视频免费观看在线| 丁香啪啪综合成人亚洲小说| 亚洲在线中文字幕| 欧美精品一区二区精品网| k8久久久一区二区三区| 亚洲成av人片观看| 久久久久国产成人精品亚洲午夜| 91视频免费看| 国内精品嫩模私拍在线| 亚洲老妇xxxxxx| 精品国产1区2区3区| 91黄色激情网站| 国产精品一区一区| 亚洲电影第三页| 国产日韩欧美一区二区三区乱码| 在线观看av一区二区| 国产美女精品一区二区三区| 亚洲一区二区在线免费观看视频| 2023国产精华国产精品| 欧美三电影在线| 国产福利一区二区三区视频| 亚洲成人你懂的| 一区在线播放视频| 精品久久久久久久久久久久久久久 | 99re8在线精品视频免费播放| 秋霞电影网一区二区| 亚洲丝袜另类动漫二区| 亚洲精品一区在线观看| 欧美日韩一级视频| 成人va在线观看| 国产在线精品一区二区不卡了| 亚洲成在线观看| 亚洲日本在线a| 久久蜜桃av一区精品变态类天堂 | 99国产一区二区三精品乱码| 极品少妇一区二区三区精品视频 | 欧美激情一区二区三区不卡 | 久久综合av免费| 欧美日韩一区二区在线观看视频| 成人va在线观看| 国产成人免费av在线| 久久99九九99精品| 日韩精品久久理论片| 一区二区三区欧美日韩| 中文字幕在线观看不卡| 久久精品在线观看| 欧美mv日韩mv亚洲| 日韩视频一区二区在线观看| 欧美无人高清视频在线观看| 91小宝寻花一区二区三区| 大胆欧美人体老妇| 精品系列免费在线观看| 青青草成人在线观看| 日韩国产欧美视频| 丝袜美腿亚洲色图| 午夜激情一区二区三区| 亚洲国产精品久久人人爱蜜臀|