电大形成性考核册c++第三次作业及答案.doc

上传人:仙人指路1688 文档编号:2199175 上传时间:2023-01-29 格式:DOC 页数:8 大小:129.51KB
返回 下载 相关 举报
电大形成性考核册c++第三次作业及答案.doc_第1页
第1页 / 共8页
电大形成性考核册c++第三次作业及答案.doc_第2页
第2页 / 共8页
电大形成性考核册c++第三次作业及答案.doc_第3页
第3页 / 共8页
电大形成性考核册c++第三次作业及答案.doc_第4页
第4页 / 共8页
电大形成性考核册c++第三次作业及答案.doc_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《电大形成性考核册c++第三次作业及答案.doc》由会员分享,可在线阅读,更多相关《电大形成性考核册c++第三次作业及答案.doc(8页珍藏版)》请在三一办公上搜索。

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) -

24、 in less than 40 seconds. Like hitting the top of the water, he will begin to slow as he approaches the more dense air closer to Earth. But this will not be enough to stop him completely.If he goes too fast or spins out of control, he has a stabilization parachute that can be deployed to slow him do

25、wn. His team hopes its not needed. Instead, he plans to deploy his 270-square-foot (25-square-meter) main chute at an altitude of around 5,000 feet (1,524 meters).In order to deploy this chute successfully, he will have to slow to 172 mph (277 kph). He will have a reserve parachute that will open automatically if he loses consciousness at mach speeds.Even if everything goes as planned, it wont. Baumgartner still will free fall at a speed that would cause you and me to pass out, and no parachute is guaranteed to work higher than 25,000 feet (7,620 meters).cause there

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 教育教学 > 成人教育


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号