電大形成性考核冊(cè)c++第三次作業(yè)及答案_第1頁(yè)
電大形成性考核冊(cè)c++第三次作業(yè)及答案_第2頁(yè)
電大形成性考核冊(cè)c++第三次作業(yè)及答案_第3頁(yè)
電大形成性考核冊(cè)c++第三次作業(yè)及答案_第4頁(yè)
電大形成性考核冊(cè)c++第三次作業(yè)及答案_第5頁(yè)
已閱讀5頁(yè),還剩4頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、專(zhuān)業(yè)好文檔計(jì)算機(jī)應(yīng)用專(zhuān)業(yè)“c+語(yǔ)言程序設(shè)計(jì)”課程作業(yè)第三次作業(yè)一、 填空題1假定p所指對(duì)象的值為28,p+1所指對(duì)象的值為62,則* p + +的值為 28 。2假定p所指對(duì)象的值為28,p+1所指對(duì)象的值為62,則* + + p的值為 62 。3假定p所指對(duì)象的值為25,p+1所指對(duì)象的值為50,則執(zhí)行“(*p)+ +;”語(yǔ)句后,p所指對(duì)象的值為 26 。4假定p所指對(duì)象的值為25,p+1所指對(duì)象的值為50,則執(zhí)行“*(p+ +);”語(yǔ)句后,p所指對(duì)象的值為 50 。5假定a是一個(gè)指針數(shù)組,則a+i所指對(duì)象的地址比a地址大 未知 字節(jié)。6假定a是一個(gè)一維數(shù)組,則ai的指針訪問(wèn)方式為 *(a+

2、i) 。7假定a是一個(gè)二維數(shù)組,則ai j的指針訪問(wèn)方式為 *(*(a+i)+j) ??赡懿徽_8假定a是一個(gè)一維數(shù)組,則ai對(duì)應(yīng)的存儲(chǔ)地址(以字節(jié)為單位)為 (char *)a+i*sizeof(a0) 。9假定一個(gè)二維數(shù)組為am n,則ai j對(duì)應(yīng)的存儲(chǔ)地址(以字節(jié)為單位)為 (char *)a+(i*n+j)*sizeof(a00) 。10假定一個(gè)二維數(shù)組am n,則ai的地址值(以字節(jié)為單位)為 (char *)a+i*n*sizeof(a00) 。11假定p是一個(gè)指向float型數(shù)據(jù)的指針,則p+1所指數(shù)據(jù)的地址比p所指數(shù)據(jù)的地址大 4 字節(jié)。12假定a為一個(gè)字符數(shù)組名,則元素a8的

3、字節(jié)地址為 8 。13假定a為一個(gè)整型數(shù)組名,則元素a4的字節(jié)地址為 16 。14假定一個(gè)結(jié)構(gòu)類(lèi)型的定義為“struct aint a,b;short c;a*d;”,則該類(lèi)型的大小為 14 字節(jié)。15假定一個(gè)結(jié)構(gòu)類(lèi)型的定義為“struct bint a8;char* b;”,則該類(lèi)型的大小為 36 字節(jié)。16假定一個(gè)結(jié)構(gòu)類(lèi)型的定義為“struct dint a;unionint b;double c;d*d3;”,則該類(lèi)型的大小為 24 字節(jié)。17假定要?jiǎng)討B(tài)分配一個(gè)類(lèi)型為worker的具有n個(gè)元素的數(shù)組,并由r指向這個(gè)動(dòng)態(tài)數(shù)組,則使用的語(yǔ)句為 r=new workern; 。18假定要訪問(wèn)一

4、個(gè)結(jié)構(gòu)x中的由a指針成員所指向的對(duì)象,則表示方法為 *(x.a) 。19假定要訪問(wèn)一個(gè)結(jié)構(gòu)指針p所指對(duì)象中的b指針成員所指的對(duì)象,則表示方法為 *(p-b) 。二、 給出下列程序運(yùn)行后的輸出結(jié)果以下結(jié)果中空格以表示1includevoid main()int a8=7,9,11,13,3,8,15,17;int *p = a;for(int i =0;i8;i + +)coutsetw(5) * p + +;if(i +1)%4 = =0)coutendl;7911133815172includevoid main()int a5=3,6,15,7,20;int *p = a;for(int

5、i = 0;i5;i + +)coutsetw(5) * p + +;coutendl;for(i =0;i5;i + +)coutsetw(5) * p;coutendl;361572020715633includevoid main()int a8 =4,8,12,16,20,24,28,32;int *p = a;docout *p ;p + =3;while(pa+8);coutendl;4 16 284includevoid main()int x =20,y =40, * p;p =&x;cout * p ;* p= x +10;p =&y;cout * pendl;* p = y

6、 +20;cout x y endl;20 4030 605includeint la(int * a,int n)int s = 0;for(int i =0;in;i + +)s + = ai;return s;void main()int a =5,10,15,20,25,30;int b =la(a,5);int c =la(a+3,2);cout b c b +2 * cendl;75 45 1656includevoid lc(int a,int b)int x = a;a = b;b = x;cout a b endl;void main()int x =15,y =36;lc(

7、x,y);cout x y endl;36 1515 367includevoid lf(int & x, int y)x = x + y;y = x + y;cout”x =” x ”,y =” y endl;void main()int x =5,y =8;cout”x =” x ”,y =” y endl;lf(x,y);cout”x =” x ”,y =” y endl;x=5,y=8x=13,y=21x=13,y=88includevoid lg(int * & a, int & m)a = new intm;int * p = a;for(int i = 0;im;i + +)*

8、p + + =2 * i +1;void main()int * p, n =5;lg(p,n);for(int i = 0;in;i + +)cout pi ;coutendl;delete p;1 3 5 7 9 9includevoid lh(int * a, int n)int * p = a + n1;whlie(ap)int x = * a;* a = * p;* p = x;a + +;p ;void main()int * d = new int5;int i;for(i = 0;i5;i + +)di=2 * i +3;coutsetw(5)di ;coutendl;lh(d

9、,5);for(i = 0;i5;i + +)coutsetw(5)di ;coutendl;delete d;35791111975310includestruct workerchar name15;/ /姓名int age;/ /年齡float pay;/ /工資;void main()worker x =”weirong”,55,640;worker y, * p;y = x;p =&x;cout y. name y. age y. payendl;coutname age+5 pay10endl;weirong 55 640weirong 60 63011includeinclude

10、struct workerchar name15;/ /姓名int age;/ /年齡float pay;/ /工資;void main()worker x;char * t =”liouting”;int d =46;float f =725;strcpy(x. name, t);x. age = d;x. pay = f;cout x. name x. age x. payendl;liouting 46 725三、 寫(xiě)出下列每個(gè)函數(shù)的功能1includevoid li(int n)int * a = new intn, * p = a + n;for(int i =0;i ai;for(

11、i = n1;i =0;i )cout *( p) ;cout n;delete a;輸入n個(gè)數(shù)并以相反的順序顯示出來(lái)。2includevoid lk(int a , int n, int * & b, int& m)float s =0;int i;for(i =0;in;i + +)s + = ai;s/= n;m = 0;for(i =0;i = s)m + +;b = new intm;int * p = b;for(i =0;i = s)* p + + = ai;將數(shù)組a中大于平均數(shù)的元素存放到動(dòng)態(tài)申請(qǐng)的數(shù)組b中,數(shù)組b的大小由m返回。3/ /struct worker/ / cha

12、r name15;/ /姓名/ / int age;/ /年齡/ / float pay;/ /工資/ /;istream & operator(istream& istr,worker& x)cout”請(qǐng)輸入一個(gè)職工記錄:姓名、年齡、工資” x. name x. age x. pay;return istr;重載istream的操作符以輸入worker結(jié)構(gòu)對(duì)象。4/ / struct strnode/ / char name15;/ /字符串域/ / strnode * next;/ /指針域/ /;void qb(strnode * & f, int n)if(n = = 0)f =nul

13、l;return;f =new strnode;cinfname;strnode * p = f;whlie( n)p = pnext= new strnode;cinpname;pnext=null;創(chuàng)建有n個(gè)結(jié)點(diǎn)的strnode類(lèi)型的鏈表,并從鍵盤(pán)輸入每個(gè)結(jié)點(diǎn)的name值。5/ / struct strnodechar name15;strnode * next;void qc(strnode * f)whlie(f)coutnamenext;遍歷鏈表并輸出所有結(jié)點(diǎn)的name數(shù)據(jù)成員if we dont do that it will go on and go on. we have to

14、 stop it; we need the courage to do it.his comments came hours after fifa vice-president jeffrey webb - also in london for the fas celebrations - said he wanted to meet ivory coast international toure to discuss his complaint.cska general director roman babaev says the matter has been exaggerated by

15、 the ivorian and the british media.blatter, 77, said: it has been decided by the fifa congress that it is a nonsense for racism to be dealt with with fines. you can always find money from somebody to pay them.it is a nonsense to have matches played without spectators because it is against the spirit

16、 of football and against the visiting team. it is all nonsense.we can do something better to fight racism and discrimination.this is one of the villains we have today in our game. but it is only with harsh sanctions that racism and discrimination can be washed out of football.the (lack of) air up th

17、ere watch mcayman islands-based webb, the head of fifas anti-racism taskforce, is in london for the football associations 150th anniversary celebrations and will attend citys premier league match at chelsea on sunday.i am going to be at the match tomorrow and i have asked to meet yaya toure, he told

18、 bbc sport.for me its about how he felt and i would like to speak to him first to find out what his experience was.uefa hasopened disciplinary proceedings against cskafor the racist behaviour of their fans duringcitys 2-1 win.michel platini, president of european footballs governing body, has also o

19、rdered an immediate investigation into the referees actions.cska said they were surprised and disappointed by toures complaint. in a statement the russian side added: we found no racist insults from fans of cska.baumgartner the disappointing news: mission aborted.the supersonic descent could happen

20、as early as sunda.the weather plays an important role in this mission. starting at the ground, conditions have to be very calm - winds less than 2 mph, with no precipitation or humidity and limited cloud cover. the balloon, with capsule attached, will move through the lower level of the atmosphere (

21、the troposphere) where our day-to-day weather lives. it will climb higher than the tip of mount everest (5.5 miles/8.85 kilometers), drifting even higher than the cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. as he crosses the boundary layer (called

22、 the tropopause),e can expect a lot of turbulence.the balloon will slowly drift to the edge of space at 120,000 feet ( then, i would assume, he will slowly step out onto something resembling an olympic diving platform.below, the earth becomes the concrete bottom of a swimming pool that he wants to l

23、and on, but not too hard. still, hell be traveling fast, so despite the distance, it will not be like diving into the deep end of a pool. it will be like he is diving into the shallow end.skydiver preps for the big jumpwhen he jumps, he is expected to reach the speed of sound - 690 mph (1,110 kph) - in less than 40 seconds. like hitting the top of the water, he will begin to slow as he approa

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論