电大广播电视大学C++语言程序设计模拟试题参考答案小抄参考.doc
专业好文档广播电视大学C+语言程序设计模拟试题2001年元月题 号一二三四五总 分 分 数 评卷人得分 一、填空(每空2分,共20分) 参考答案1.C+源程序文件扩展名为_。2.unsigned long 型数据占_字节存储空间。3.执行语句cout<<"d:datac+test.exe";后,输出结果是_。4.表达式8|3的结果是_。5.全局变量和_若在定义时未进行初始化,则自动初始化为0。6.将s初始化为值是"Hello!"的指针常量,初始化语句是_。7.类中的成员只能为该类的成员函数及该类的派生类中的成员函数访问,则应加上访问属性_。8.定义输出文件流f,并以追加数据方式打开相应文件"a:aaa.dat",定义f的语句是_。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;,下列表示引用的方法中,( )是正确的。 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的类型分别是( )。 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 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);cout<<m<<' '<<n<<endl; m=f2(n);cout<<m<<' '<<n<<endl; 写出结果。 评卷人得分 四、(每题10分,共20分)参考答案1.写出下列程序的执行结果。 # include <iostream.h> 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+; cout<<a<<endl; if(i<j) if(i!=3) if(!k) a=1; else if(k) a=5; a+=2; cout<<a<<endl; 2.设a盘上文本文件aaa.dat中保存有0至100之间的所有奇数,下列程序将全部数据及其和输出至屏幕上,请将程序补充完全。 # include <stdlib.h> # include _ void main(void) _ f1("a:aaa.dat",ios:in|ios:nocreate); if (!f1) cerr<<"a:aaa.dat file not open!"<<endl; exit(1); int x,s=0; while (_)f1>>x;cout<<x<<' ';_; f1._; 评卷人得分 五、(每题10分,共20分)参考答案1.用while循环编程,求自然数1至100之间各奇数平方和并输出。 2.设有函数void sum(int score 5,int row);,它将数组score每行后四个元素之和用首元素保存。试编写这个函数 编写主函数并初始化相应实参调用这个函数,并输出结果。关闭窗口广播电视大学C+语言程序设计模拟试题答案2001年元月一、填空(每空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 * week="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 #include<iostream.h>void main()int i=1,sum=0;while(i<=100)sum+=i*i;i+=2;cout<<"sum="<<sum<<endl; 2#include<iostream.h>void sum(int score5,int row) for(int i=0;i<row;i+) scorei0=0; for(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;i<5;i+) cout<<ai0<<endl; 关闭窗口 "If we don't 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 FA's 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 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 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 there Watch mCayman Islands-based Webb, the head of Fifa's anti-racism taskforce, is in London for the Football Association's 150th anniversary celebrations and will attend City's 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 it's about how he felt and I would like to speak to him first to find out what his experience was."Uefa has opened disciplinary proceedings against CSKA for the "racist behaviour of their fans" during City's 2-1 win.Michel Platini, president of European football's governing body, has also ordered an immediate investigation into the referee's actions.CSKA said they were "surprised and disappointed" by Toure's 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 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 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 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, he'll 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 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 down. His team hopes it's 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 won't. 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