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

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

?? apd.htm

?? good book for learning c++ standard language
?? HTM
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
	<B>3. Is it possible to write a <TT>for</TT> loop with a body that is never executed?</B><BR>
	<BR>
	Yes, if the condition is <TT>FALSE</TT> after the initialization, the body of the
	<TT>for</TT> loop will never execute. Here's an example:
</DL>

<PRE><FONT COLOR="#0066FF">for (int x = 100; x &lt; 100; x++)
</FONT></PRE>

<DL>
	<DD><B>4. Is it possible to nest <TT>while</TT> loops within <TT>for</TT> loops?</B><BR>
	<BR>
	Yes. Any loop can be nested within any other loop.<BR>
	<BR>
	<B>5. Is it possible to create a loop that never ends? Give an example.<BR>
	</B><BR>
	Yes. Following are examples for both a <TT>for</TT> loop and a <TT>while</TT> loop:
</DL>

<PRE><FONT COLOR="#0066FF">for(;;)
{
    // This for loop never ends!
}
while(1)
{
    // This while loop never ends!
</FONT></PRE>
<PRE><FONT COLOR="#0066FF">
}
</FONT></PRE>

<DL>
	<DD><B>6. What happens if you create a loop that never ends?<BR>
	</B><BR>
	Your program hangs, and you usually must reboot the computer.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading23"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1.</B> What is the value of <TT>x</TT> when the <TT>for</TT> loop completes?
</DL>

<PRE><FONT COLOR="#0066FF">for (int x = 0; x &lt; 100; x++)
100
</FONT></PRE>

<DL>
	<DD><B>2.</B> Write a nested <TT>for</TT> loop that prints a 10x10 pattern of <TT>0</TT>s.
</DL>

<PRE><FONT COLOR="#0066FF">for (int i = 0; i&lt; 10; i++)
{
    for ( int j = 0; j&lt; 10; j++)
       cout &lt;&lt; &quot;0&quot;;
    cout &lt;&lt; &quot;\n&quot;;
}
</FONT></PRE>

<DL>
	<DD><B>3</B>. Write a <TT>for</TT> statement to count from 100 to 200 by 2s.
</DL>

<PRE><FONT COLOR="#0066FF">for (int x = 100; x&lt;=200; x+=2)
</FONT></PRE>

<DL>
	<DD><B>4.</B> Write a <TT>while</TT> loop to count from 100 to 200 by 2s.
</DL>

<PRE><FONT COLOR="#0066FF">int x = 100;
while (x &lt;= 200)
    x+= 2;
</FONT></PRE>

<DL>
	<DD><B>5.</B> Write a <TT>do...while</TT> loop to count from 100 to 200 by 2s.
</DL>

<PRE><FONT COLOR="#0066FF">int x = 100;
do
{
    x+=2;
} while (x &lt;= 200);
</FONT></PRE>

<DL>
	<DD><B>6.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">int counter = 0
while (counter &lt; 10)
{ 
    cout &lt;&lt; &quot;counter: &quot; &lt;&lt; counter;
    counter++;
}
</FONT></PRE>

<DL>
	<DD><TT>counter</TT> is never incremented and the <TT>while</TT> loop will never
	terminate.<BR>
	<BR>
	<B>7.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">for (int counter = 0; counter &lt; 10; counter++);
    cout &lt;&lt; counter &lt;&lt; &quot;\n&quot;;
</FONT></PRE>

<DL>
	<DD>There is a semicolon after the loop, and the loop does nothing. The programmer
	may have intended this, but if <TT>counter</TT> was supposed to print each value,
	it won't.<BR>
	<BR>
	<B>8.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">int counter = 100;
while (counter &lt; 10)
{
    cout &lt;&lt; &quot;counter now: &quot; &lt;&lt; counter;
    counter--;
}
</FONT></PRE>

<DL>
	<DD><TT>counter</TT> is initialized to <TT>100</TT>, but the test condition is that
	if it is less than 10, the test will fail and the body will never be executed. If
	line 1 were changed to <TT>int counter = 5;</TT>, the loop would not terminate until
	it had counted down past the smallest possible <TT>int</TT>. Because <TT>int</TT>
	is <TT>signed</TT> by default, this would not be what was intended.<BR>
	<BR>
	<B>9.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">cout &lt;&lt; &quot;Enter a number between 0 and 5: &quot;;
cin &gt;&gt; theNumber;
switch (theNumber)
{
   case 0:
         doZero();
   case 1:              // fall through
   case 2:              // fall through
   case 3:              // fall through
   case 4:              // fall through
   case 5: 
         doOneToFive();
         break;
   default:
         doDefault();
         break;
}
</FONT></PRE>

<DL>
	<DD><TT>Case 0</TT> probably needs a <TT>break</TT> statement. If it does not, it
	should be documented with a comment.
</DL>

<H3><A NAME="Heading24"></A><FONT COLOR="#000077">Day 8</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading25"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What operator is used to determine the address of a variable?<BR>
	</B><BR>
	The address of operator (<TT>&amp;</TT>) is used to determine the address of any
	variable.<BR>
	<B><BR>
	2. What operator is used to find the value stored at an address held in a pointer?<BR>
	</B><BR>
	The dereference operator (<TT>*</TT>) is used to access the value at an address in
	a pointer.<BR>
	<BR>
	<B>3. What is a pointer?<BR>
	</B><BR>
	A pointer is a variable that holds the address of another variable.<BR>
	<BR>
	<B>4. What is the difference between the address stored in a pointer and the value
	at that </B>address?<BR>
	<BR>
	The address stored in the pointer is the address of another variable. The value stored
	at that address is any value stored in any variable. The indirection operator (<TT>*</TT>)
	returns the value stored at the address, which itself is stored in the pointer.<BR>
	<BR>
	<B>5. What is the difference between the indirection operator and the address of
	oper-ator?<BR>
	</B><BR>
	The indirection operator returns the value at the address stored in a pointer. The
	address of operator (<TT>&amp;</TT>) returns the memory address of the variable.<BR>
	<BR>
	<B>6. What is the difference between <TT>const int * ptrOne</TT> and <TT>int * const
	ptrTwo</TT>?<BR>
	</B><BR>
	The <TT>const int * ptrOne</TT> declares that <TT>ptrOne</TT> is a pointer to a constant
	integer. The integer itself cannot be changed using this pointer.<BR>
	The <TT>int * const ptrTwo</TT> declares that <TT>ptrTwo</TT> is a constant pointer
	to an integer. Once it is initialized, this pointer cannot be reassigned.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading26"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1.</B> What do these declarations do?
	<DL>
		<DD><B><BR>
		a.</B> <TT>int * pOne;</TT><BR>
		<B>b</B>. <TT>int vTwo;</TT><BR>
		<B>c.</B> <TT>int * pThree = &amp;vTwo;</TT><BR>
		<B><BR>
		a.</B> <TT>int * pOne;</TT> declares a pointer to an integer.<BR>
		<B>b.</B> <TT>int vTwo;</TT> declares an integer variable.<BR>
		<B>c.</B> <TT>int * pThree = &amp;vTwo;</TT> declares a pointer to an integer and
		initializes it with the address of another variable.
	</DL>
	<DD><B><BR>
	2.</B> If you have an <TT>unsigned short</TT> variable named <TT>yourAge</TT>, how
	would you declare a pointer to manipulate <TT>yourAge</TT>?
</DL>

<PRE><FONT COLOR="#0066FF">unsigned short *pAge = &amp;yourAge;
</FONT></PRE>

<DL>
	<DD><B>3.</B> Assign the value <TT>50</TT> to the variable <TT>yourAge</TT> by using
	the pointer that you declared in Exercise 2.
</DL>

<PRE><FONT COLOR="#0066FF">*pAge = 50;
</FONT></PRE>

<DL>
	<DD><B>4.</B> Write a small program that declares an integer and a pointer to integer.
	Assign the address of the integer to the pointer. Use the pointer to set a value
	in the integer variable.
</DL>

<PRE><FONT COLOR="#0066FF">int theInteger;
int *pInteger = &amp;theInteger;
*pInteger = 5;
</FONT></PRE>

<DL>
	<DD><B>5.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">#include &lt;iostream.h&gt;
int main()
{
     int *pInt;
     *pInt = 9;
     cout &lt;&lt; &quot;The value at pInt: &quot; &lt;&lt; *pInt;
return 0;
}
</FONT></PRE>

<DL>
	<DD><TT>pInt</TT> should have been initialized. More importantly, because it was
	not initialized and was not assigned the address of any memory, it points to a random
	place in memory. Assigning <TT>9</TT> to that random place is a dangerous bug.<BR>
	<BR>
	<B>6.</B> BUG BUSTERS: What is wrong with this code?
</DL>

<PRE><FONT COLOR="#0066FF">int main()
{
    int SomeVariable = 5;
    cout &lt;&lt; &quot;SomeVariable: &quot; &lt;&lt; SomeVariable &lt;&lt; &quot;\n&quot;;
    int *pVar = &amp; SomeVariable;
    pVar = 9;
    cout &lt;&lt; &quot;SomeVariable: &quot; &lt;&lt; *pVar &lt;&lt; &quot;\n&quot;;
return 0;
}
</FONT></PRE>

<DL>
	<DD>Presumably, the programmer meant to assign <TT>9</TT> to the value at <TT>pVar</TT>.
	Unfortunately, <TT>9</TT> was assigned to be the value of <TT>pVar</TT> because the
	indirection operator (<TT>*</TT>) was left off. This will lead to disaster if <TT>pVar</TT>
	is used to assign a value.
</DL>

<H3 ALIGN="CENTER"></H3>
<H3><A NAME="Heading27"></A><FONT COLOR="#000077">Day 9</FONT></H3>
<H4 ALIGN="CENTER"><A NAME="Heading28"></A><FONT COLOR="#000077">Quiz</FONT></H4>

<DL>
	<DD><B>1. What is the difference between a reference and a pointer?<BR>
	</B><BR>
	A reference is an alias, and a pointer is a variable that holds an address. References
	cannot be null and cannot be assigned to.<BR>
	<BR>
	<B>2. When must you use a pointer rather than a reference?<BR>
	</B><BR>
	When you may need to reassign what is pointed to, or when the pointer may be null.<BR>
	<BR>
	<B>3. What does <TT>new</TT> return if there is insufficient memory to make your
	<TT>new</TT> object?<BR>
	</B><BR>
	A null pointer (<TT>0</TT>).<BR>
	<BR>
	<B>4. What is a constant reference?<BR>
	</B><BR>
	This is a shorthand way of saying &quot;a reference to a constant object.&quot;<BR>
	<BR>
	<B>5. What is the difference between passing by reference and passing a reference?<BR>
	</B><BR>
	Passing by reference means not making a local copy. It can be accomplished by passing
	a reference or by passing a pointer.
</DL>

<H4 ALIGN="CENTER"><A NAME="Heading29"></A><FONT COLOR="#000077">Exercises</FONT></H4>

<DL>
	<DD><B>1</B>. Write a program that declares an <TT>int</TT>, a reference to an <TT>int</TT>,
	and a pointer to an <TT>int</TT>. Use the pointer and the reference to manipulate
	the value in the <TT>int</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">int main()
{
int varOne;
int&amp; rVar = varOne;
int* pVar = &amp;varOne;
rVar = 5;
*pVar = 7;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>2.</B> Write a program that declares a constant pointer to a constant integer.
	Initialize the pointer to an integer variable, <TT>varOne</TT>. Assign <TT>6</TT>
	to <TT>varOne</TT>. Use the pointer to assign <TT>7</TT> to <TT>varOne</TT>. Create
	a second integer variable, <TT>varTwo</TT>. Reassign the pointer to <TT>varTwo</TT>.
</DL>

<PRE><FONT COLOR="#0066FF">int main()
{
   int varOne;
   const int * const pVar = &amp;varOne;
   *pVar = 7;
   int varTwo;
   pVar = &amp;varTwo;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>3.</B> Compile the program in Exercise 2. What produces errors? What produces
	warnings?<BR>
	You can't assign a value to a constant object, and you can't reassign a constant
	pointer.<BR>
	<BR>
	<B>4.</B> Write a program that produces a stray pointer.
</DL>

<PRE><FONT COLOR="#0066FF">int main()
{
int * pVar;
*pVar = 9;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>5.</B> Fix the program from Exercise 4.
</DL>

<PRE><FONT COLOR="#0066FF">int main()
{
int VarOne;
int * pVar = &amp;varOne;
*pVar = 9;
return 0;
}
</FONT></PRE>

<DL>
	<DD><B>6.</B> Write a program that produces a memory leak.
</DL>

<PRE><FONT COLOR="#0066FF">int FuncOne();
int main()
{
   int localVar = FunOne();
   cout &lt;&lt; &quot;the value of localVar is: &quot; &lt;&lt; localVar;
return 0;
}

int FuncOne()
{
   int * pVar = new int (5);
   return *pVar;
}
</FONT></PRE>

<DL>
	<DD><B>7.</B> Fix the program from Exercise 6.
</DL>

<PRE><FONT COLOR="#0066FF">void FuncOne();
int main()
{
   FuncOne();
return 0;
}

void FuncOne()
{
   int * pVar = new int (5);
   cout &lt;&lt; &quot;the value of *pVar is: &quot; &lt;&lt; *pVar ;
}
</FONT></PRE>

<DL>
	<DD><B>8.</B> BUG BUSTERS: What is wrong with this program?
</DL>

<PRE><FONT COLOR="#0066FF">1:     #include &lt;iostream.h&gt;
2:
3:     class CAT
4:     {
5:        public:
6:           CAT(int age) { itsAge = age; }
7:           ~CAT(){}
8:           int GetAge() const { return itsAge;}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
石原莉奈在线亚洲二区| 激情欧美日韩一区二区| 精品福利一二区| 91黄色免费版| 国产成人av电影在线观看| 99精品视频在线免费观看| 日韩一区精品字幕| 亚洲精品视频在线看| 久久亚洲影视婷婷| 日韩一区二区三区av| 欧美亚洲国产一区在线观看网站| 国产自产高清不卡| 日韩精品91亚洲二区在线观看| 国产精品亲子伦对白| 2023国产精华国产精品| 欧美一区二区在线不卡| 欧美在线综合视频| 97久久人人超碰| 成人性生交大片免费看视频在线| 久久激情五月婷婷| 日韩影院免费视频| 天天av天天翘天天综合网色鬼国产| 中文字幕一区二区在线播放| 精品毛片乱码1区2区3区| 91精品午夜视频| 欧美日韩成人在线| 欧洲国内综合视频| 色网站国产精品| 91免费看`日韩一区二区| 成人免费毛片a| 国产精品456| 国产黄人亚洲片| 国产精品综合二区| 国产乱人伦偷精品视频免下载| 久久99久国产精品黄毛片色诱| 奇米影视一区二区三区小说| 舔着乳尖日韩一区| 亚洲国产精品欧美一二99| 一区二区三区欧美| 亚洲欧美另类久久久精品2019| 亚洲人123区| 亚洲精品视频一区| 有码一区二区三区| 亚洲五月六月丁香激情| 亚洲bt欧美bt精品777| 亚洲成人tv网| 奇米888四色在线精品| 九九九久久久精品| 国产精品综合av一区二区国产馆| 国产精品亚洲а∨天堂免在线| 国产成人精品免费视频网站| 成人a区在线观看| 99re热视频这里只精品| 欧洲另类一二三四区| 欧美男生操女生| 欧美成人video| 久久亚洲影视婷婷| 国产精品色一区二区三区| 亚洲视频综合在线| 亚洲高清免费视频| 精油按摩中文字幕久久| 成人午夜伦理影院| 欧美综合一区二区| 91精品国产综合久久福利| xf在线a精品一区二区视频网站| 久久精品一区四区| 亚洲啪啪综合av一区二区三区| 无码av免费一区二区三区试看 | 国产一级精品在线| 国内精品在线播放| 色综合色综合色综合| 欧美一区二区人人喊爽| 欧美激情一区二区| 亚洲一级二级三级| 国产麻豆一精品一av一免费| 色八戒一区二区三区| 日韩精品一区二区三区老鸭窝| 亚洲国产成人一区二区三区| 亚洲国产成人tv| 国产精品一区三区| 91黄色免费版| 国产在线日韩欧美| 91一区二区在线观看| 在线不卡中文字幕| 久久影院午夜片一区| 国产精品第13页| 日韩激情中文字幕| 国产99久久久国产精品潘金网站| 欧美视频在线一区| 久久免费看少妇高潮| 亚洲国产一区二区在线播放| 国产成人精品综合在线观看| 欧美男生操女生| 国产精品久久久久久久久久免费看 | 国内久久婷婷综合| 欧美亚洲免费在线一区| 国产精品色在线| 久久精品噜噜噜成人av农村| 在线国产电影不卡| 国产精品热久久久久夜色精品三区| 蜜乳av一区二区三区| 欧洲亚洲国产日韩| 亚洲视频中文字幕| 国产91精品一区二区| 精品欧美乱码久久久久久 | 国产成人免费网站| 91精品国产综合久久精品图片| 亚洲欧美aⅴ...| 粉嫩久久99精品久久久久久夜| 欧美videos大乳护士334| 婷婷一区二区三区| 欧美性猛交一区二区三区精品| 日韩毛片一二三区| 风间由美性色一区二区三区| 久久综合久久99| 精品午夜一区二区三区在线观看| 欧美日韩日本视频| 亚洲一区二区精品视频| 91丨porny丨在线| 国产精品久久免费看| 国产不卡视频在线播放| 久久免费美女视频| 国内外成人在线视频| 精品国产凹凸成av人导航| 日本不卡视频在线| 91精品国产91综合久久蜜臀| 亚洲国产cao| 欧美日韩一区三区四区| 亚洲一区二区三区在线看| 91国产视频在线观看| 亚洲激情校园春色| 欧美性一二三区| 亚洲1区2区3区4区| 欧美日韩免费不卡视频一区二区三区| 国内国产精品久久| 久久久久久久久蜜桃| 国产精品亚洲成人| 中国av一区二区三区| av电影在线观看一区| 日韩久久一区二区| 91尤物视频在线观看| 一区二区三区精品在线| 在线精品视频一区二区| 香蕉加勒比综合久久| 91精品国产综合久久久蜜臀粉嫩 | 欧美一卡在线观看| 狠狠狠色丁香婷婷综合激情| 国产午夜精品一区二区三区嫩草 | 久久久精品国产99久久精品芒果 | 另类综合日韩欧美亚洲| www亚洲一区| 成人黄色免费短视频| 亚洲色图另类专区| 欧美视频一区在线| 免费看日韩精品| 国产亚洲一区二区三区四区| 99re成人精品视频| 亚洲成人av一区| 久久久久亚洲蜜桃| 91视频精品在这里| 亚洲成人激情社区| xfplay精品久久| 色天使色偷偷av一区二区| 婷婷亚洲久悠悠色悠在线播放| 欧美videos大乳护士334| 99在线精品观看| 亚洲成av人影院在线观看网| 久久免费电影网| 91蝌蚪porny| 寂寞少妇一区二区三区| 亚洲三级电影网站| 日韩午夜在线播放| 99久久国产综合精品色伊| 日韩国产一二三区| 国产精品理伦片| 日韩午夜精品视频| 91在线观看地址| 精品无码三级在线观看视频| 亚洲柠檬福利资源导航| 日韩欧美激情四射| 一本色道久久综合亚洲精品按摩| 免费在线欧美视频| 亚洲色图欧洲色图婷婷| 日韩欧美第一区| 欧美中文字幕亚洲一区二区va在线 | 日韩国产一二三区| 亚洲欧洲日韩综合一区二区| 日韩欧美的一区| 欧美影院午夜播放| 国产 欧美在线| 蜜臀精品一区二区三区在线观看| 中文字幕一区二区三| 日韩欧美高清一区| 欧美性色黄大片手机版| 成人性生交大片免费看中文网站| 日本亚洲最大的色成网站www| 亚洲欧美日韩国产另类专区| 国产色综合久久| 欧美成人激情免费网| 欧美精品vⅰdeose4hd|