电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考_第1页
电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考_第2页
电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考_第3页
电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考_第4页
电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

1、广播电视大学c+语言程序设计模拟试题2001年元月题 号一二三四五总 分分 数评卷人得分 一、填空(每空2分,共20分) 参考答案1.c+源程序文件扩展名为_。2.unsigned long 型数据占_字节存储空间。3.执行语句coutd:datac+test.exe;后,输出结果是_。4.表达式8|3的结果是_。5.全局变量和_若在定义时未进行初始化,则自动初始化为0。6.将s初始化为值是hello!的指针常量,初始化语句是_。7.类中的成员只能为该类的成员函数及该类的派生类中的成员函数访问,则应加上访问属性_。8.定义输出文件流f,并以追加数据方式打开相应文件a:aaa.dat,定义f的语

2、句是_。9.设文件f.cpp中的一个函数要访问在另一个文件中定义的int型变量x,则在f.cpp中x应定义为_。10.函数模板的说明格式是:template_函数定义。评卷人得分二、单项选择题(每空2分,共20分)参考答案1.类型修饰符unsigned修饰( )类型是错误的。 a char b int c long int d float2.下列变量名中,( )是合法的。 a _var b bye-bye c int d 123_cc3.设int a=3,* p=&a;,则*p的值是( )。 a 变量a的地址值 b 无意义 c 变量p的地址值 d 34.设int m=0;,下列表示引用的方法中

3、,( )是正确的。 a int &x=m; b int &y=10; c int &z; d float &t=&m5.循环for(int i=0,x=0;!x&i=5;i+);的循环体执行次数是( )。 a 5 b 6 c 1 d 无限 6.磁盘文件操作时,在打开磁盘文件的访问方式中,( )是以追加数据 方式打开文件的。 a in b out c app d ate7.类x中,若没有定义构造函数,则默认的构造函数是( )。 a x ( ) b x (x & x) *this=x; c x ( ) d 不存在8.设int * p2=&x,* p1=a;*p2=*b;则变量a和b的类型分别是(

4、)。 a int和int b int * 和int c int和int * d int * 和int *9.设p为指针变量,则以下表达式正确的是( )。 a -p+ b -+p c -(p+5) d (p-5)+ 10.设void f1(int &x,char * p);int m;char s =c+;以下调用合法的是( )。 a f1(&m,&s); b f1(&m,s); c f1(m,s); d f1(m,&s);评卷人得分三、回答问题(每题4分,共20分)参考答案1.设int a34;double b345; 请写出数组指针pa和pb的定义,使其分别与数组名a和b等价。2.设int

5、f1(int n,char * s);char * f2(int n,char * s); 请写出函数指针pf1和pf2的定义,使其分别指向上述两个函数。3.请初始化一维指针数组week。其初值表初值为sun,mon,tue,wed,thu,fri和sat。 4.要使语句p1=new int(10) ;p2=new double 10;能正常执行,写出p1和p2的定义。 5.设有int f1(int n)n+=2;return n*n; int f2(int &n)n+=2;return n*n; 执行 int m=5,n=3; m=f1(n);coutm nendl; m=f2(n);cou

6、tm nendl; 写出结果。评卷人得分四、(每题10分,共20分)参考答案1.写出下列程序的执行结果。 # include void main() int i=1,j=2,k=3,a=10; if (!i) a-; else if(j) if(k) a=5; else a=6; a+; coutaendl; if(ij) if(i!=3) if(!k) a=1; else if(k) a=5; a+=2; coutaendl; 2.设a盘上文本文件aaa.dat中保存有0至100之间的所有奇数,下列程序将全部数据及其和输出至屏幕上,请将程序补充完全。 # include # include

7、_ void main(void) _ f1(a:aaa.dat,ios:in|ios:nocreate); if (!f1) cerra:aaa.dat file not open!x;coutx ;_; f1._; 评卷人得分五、(每题10分,共20分)参考答案1.用while循环编程,求自然数1至100之间各奇数平方和并输出。2.设有函数void sum(int score 5,int row);,它将数组score每行后四个元素之和用首元素保存。试编写这个函数 编写主函数并初始化相应实参调用这个函数,并输出结果。关闭窗口广播电视大学c+语言程序设计模拟试题答案2001年元月一、填空(每

8、空2分,共20分) 返回1.cpp2.43.d:datac+test.exe4.115.静态局部变6.char * const s=hello!;7.protected8.ofstream f(a:aaa.dat,ios:app);9.extern int x;10.二、单项选择题(每空2分,共20分)返回1d2a3d4a5b6c7a8d9b10c三、回答问题(每题4分,共20分)返回1int (*pa)4=a;double(*pb)45=b;2int (* pf1)(int n,char * s)=f1;char *( * pf2)(int n,char * s)=f2; 3char * w

9、eek=sun,mon,tue,wed,thu,fri,sat; 4int * p1 ;double * p2;5 25 36 25 5四、(每题10分,共20分)返回1 6 7 2 fstream.h ifstream !f1.eof() s+=x close()五、(每题10分,共20分)返回1 #includevoid main()int i=1,sum=0;while(i=100)sum+=i*i;i+=2;coutsum=sumendl; 2#includevoid sum(int score5,int row) for(int i=0;irow;i+) scorei0=0; for

10、(int j=1;j=4;j+) scorei0+=scoreij; void main() int a55=0,50,60,70,80,0,51,61,71,81, 0,52,62,72,82,0,53,63,73,83,0,54,64,74,84; sum(a,5); for(int i=0;i5;i+) coutai0endl; 关闭窗口 待添加的隐藏文字内容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 hour

11、s 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 the ivorian and the british media.blatter, 77, said: it has

12、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 of football and against the visiting team. it is all nonsens

13、e.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 there watch mcayman islands-based webb, the head of fifas anti-

14、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 bbc sport.for me its about how he felt and i would like to s

15、peak 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 ordered an immediate investigation into the referees actions.c

16、ska 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 as early as sunda.the weather plays an important role in this

17、 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 (the troposphere) where our day-to-day weather lives. it will

18、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 the tropopause),e can expect a lot of turbulence.the balloon

19、 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 land on, but not too hard. still, hell be traveling fast, so d

20、espite 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 approaches the more dense air closer to earth. but this will not be enough to stop him completely.if h

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论