电大形成性考核册c++第三次作业及答案_第1页
电大形成性考核册c++第三次作业及答案_第2页
电大形成性考核册c++第三次作业及答案_第3页
电大形成性考核册c++第三次作业及答案_第4页
电大形成性考核册c++第三次作业及答案_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、专业好文档计算机应用专业“c+语言程序设计”课程作业第三次作业一、 填空题1假定p所指对象的值为28,p+1所指对象的值为62,则* p + +的值为 28 。2假定p所指对象的值为28,p+1所指对象的值为62,则* + + p的值为 62 。3假定p所指对象的值为25,p+1所指对象的值为50,则执行“(*p)+ +;”语句后,p所指对象的值为 26 。4假定p所指对象的值为25,p+1所指对象的值为50,则执行“*(p+ +);”语句后,p所指对象的值为 50 。5假定a是一个指针数组,则a+i所指对象的地址比a地址大 未知 字节。6假定a是一个一维数组,则ai的指针访问方式为 *(a+

2、i) 。7假定a是一个二维数组,则ai j的指针访问方式为 *(*(a+i)+j) 。可能不正确8假定a是一个一维数组,则ai对应的存储地址(以字节为单位)为 (char *)a+i*sizeof(a0) 。9假定一个二维数组为am n,则ai j对应的存储地址(以字节为单位)为 (char *)a+(i*n+j)*sizeof(a00) 。10假定一个二维数组am n,则ai的地址值(以字节为单位)为 (char *)a+i*n*sizeof(a00) 。11假定p是一个指向float型数据的指针,则p+1所指数据的地址比p所指数据的地址大 4 字节。12假定a为一个字符数组名,则元素a8的

3、字节地址为 8 。13假定a为一个整型数组名,则元素a4的字节地址为 16 。14假定一个结构类型的定义为“struct aint a,b;short c;a*d;”,则该类型的大小为 14 字节。15假定一个结构类型的定义为“struct bint a8;char* b;”,则该类型的大小为 36 字节。16假定一个结构类型的定义为“struct dint a;unionint b;double c;d*d3;”,则该类型的大小为 24 字节。17假定要动态分配一个类型为worker的具有n个元素的数组,并由r指向这个动态数组,则使用的语句为 r=new workern; 。18假定要访问一

4、个结构x中的由a指针成员所指向的对象,则表示方法为 *(x.a) 。19假定要访问一个结构指针p所指对象中的b指针成员所指的对象,则表示方法为 *(p-b) 。二、 给出下列程序运行后的输出结果以下结果中空格以表示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三、 写出下列每个函数的功能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个数并以相反的顺序显示出来。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;将数组a中大于平均数的元素存放到动态申请的数组b中,数组b的大小由m返回。3/ /struct worker/ / cha

12、r name15;/ /姓名/ / int age;/ /年龄/ / float pay;/ /工资/ /;istream & operator(istream& istr,worker& x)cout”请输入一个职工记录:姓名、年龄、工资” x. name x. age x. pay;return istr;重载istream的操作符以输入worker结构对象。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;创建有n个结点的strnode类型的链表,并从键盘输入每个结点的name值。5/ / struct strnodechar name15;strnode * next;void qc(strnode * f)whlie(f)coutnamenext;遍历链表并输出所有结点的name数据成员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. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论