《中央电大专科C++语言程序设计试题小抄参考.doc》由会员分享,可在线阅读,更多相关《中央电大专科C++语言程序设计试题小抄参考.doc(6页珍藏版)》请在三一办公上搜索。
1、中央广播电视大学2013期末考试C+语言程序设计 一、单选题(每小题2分,共20分) 1由C+源程序文件编译而成的目标文件的缺省扩展名为( )。 Aobj B1ik Cexe Dcpp 2程序运行中需要从键盘上输人多于一个数据时,各数据之间需要使用( )符号作为分隔符。 A空格或逗号 B逗号或回车 C逗号或分号 D空格或回车 3设x是一个bool型的逻辑量,y的值为10,则表达式x&y的值为( )。 A1 B0 Cx的值 Dx的相反值 4任何for语句都能够被改写为( )语句。 A复合 Bif Cswitch Dwhile 5break语句叫做( )语句。 A中断退出循环或开关 B返回C转向
2、D继续6在下面的一维数组定义中,( )语句有语法错误。 Aint a=1,2,3 Bint al0=0 Cint a Dint a5 7下面的( )保留字不能作为函数的返回类型o Avoid Bint Cnew D1ong 8下面的函数声明中,( )是void BC(int a,int b);的重载函数。 Aint BC(int x,int y) BvoidBC(int a,char b) Cfloat AA(int a,char b) Dint BC(int a,intb=0) 9当一个字符指针指向具有n个字节的存储空间时,它所能存储字符串的最大长度为( )。 An Bn+1 Cn一1 Dn
3、一2 10假定AB为一个类,则该类的拷贝构造函数的声明语句为( )。 AAB&(AB x) BAB(AB x) CAB(AB* x) DAB(AB&)二、填空题(每小题2分,共20分) 1C+语言中每条复合语句以左花括号开始,并以_结束。 2假定一个枚举类型的定义为“enum RAab,ac,ad,ae;”,则ac的值为_。 3十进制数25表示成符合C+语言规则的八进制数为_。 4表达式xx+y表示成复合赋值表达式为_。 5若x5,则x5的逻辑值为_。 6。假定一个一维数组的定义为char* a8”,则该数组占用个字节的存储空间。 7假定x10,则表达式2+x+的值为_。 8假定p所指对象的值
4、为25,p+l所指对象的值为46,则*+p的值为_。 9假定要动态分配一个类型为int的具有n个元素的数组,并由r指向这个动态数组,则使用的语句为int * r_。 10设px指向一个类的动态分配的对象,则执行delete px;”语句时,将自动调用该类的_。三、写出下列每个程序运行后的输出结果(每小题6分,共30分) 1#inlude Voidmain() int n=5, sum=0; while(n) sum+=n; n-; cout”sum=”sumendl; 运行结果: 2#include Const int N6; VOidmain() intaN=76,83,54,62,40,6
5、5; int cl, C2; c1c2a0; for(int i=l;ic1)c1=ai else if(aic2) c2ai; coutclc2endl; 运行结果: 3#include Void main() int a8:4,8,15,16,20,30,48,62; int *pa; while(pa+8) cout*p; p+3; Coutendl; 运行结果:4#include int LF(int x,inty) x=x+y;yx+y; return x+y; void main() int x5,y8; coutLF(1,2)LF(x,y)endl; 运行结果: 5#inclUd
6、e Class A int a,b; public: A()ab0; A(int aa,int bb) aaa;bbb; cOutabb)return 1; else if(a=b)return 0; else return -l; 函数功能: 2int LK(int a,int n) float s0; int i; for(i=0;in;i+)s+=ai; sn; int m0; for(i0;i=s)m+; return m; 函数功能: 3Int WD(int a,int n) Int ma0; for(int i=1;im) mai; return m; 函数功能:五、按题目要求编写
7、程序(6分) 已知6a30、15b36,求出满足不定方程2a+5b126的全部整数组解。如(13, 20)就是其中的一组解,并按此格式输出每组解。待添加的隐藏文字内容2If we dont do that it will go on and go on. We have to 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 t
8、o meet Ivory Coast international Toure to discuss his complaint.CSKA general director Roman Babaev says the matter has been exaggerated by 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 c
9、an always find money from somebody to pay them.It is a nonsense to have matches played without spectators because it is against the spirit 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 t
10、oday 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 there Watch mCayman Islands-based Webb, the head of Fifas anti-racism taskforce, is in London for the Football Associations 150th anniversary celebrations and will
11、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 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
12、 CSKAfor the racist behaviour of their fans duringCitys 2-1 win.Michel Platini, president of European footballs governing body, has also ordered an immediate investigation into the referees actions.CSKA said they were surprised and disappointed by Toures complaint. In a statement the Russian side ad
13、ded: We found no racist insults from fans of CSKA.Baumgartner the disappointing news: Mission aborted.The supersonic descent could happen 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 pr
14、ecipitation or humidity and limited cloud cover. The balloon, with capsule attached, will move through the lower level of the atmosphere (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
15、 cruising altitude of commercial airliners (5.6 miles/9.17 kilometers) and into the stratosphere. As he crosses the boundary layer (called 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 o
16、ut onto something resembling an Olympic diving platform.Below, the Earth becomes the concrete bottom of a swimming pool that he wants to land 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 di
17、ving 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 approaches the more dense air closer to Earth. But this will not be enoug
18、h 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 down. 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)
19、.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