《2014年电大面向对象程序设计期末复习指导参考【精编版】》由会员分享,可在线阅读,更多相关《2014年电大面向对象程序设计期末复习指导参考【精编版】(5页珍藏版)》请在金锄头文库上搜索。
1、电大面向对象程序设计期末复习指导小抄一、单项选题1字符串”a+b=12n” 的长度为( ) 。A. 6 B. 7 C. 8 D. 92. x0 | y=5 的相反表达式为( ) 。A. x0 | y!=5 D. x0 & y=53. 循环体有可能一次都不执行的语句为( ) 。A. for 循环 B. switch 循环C. do 循环 D. 任一种循环4. 函数调用 func(exp1,exp2,exp3),exp4,exp5)中所含实参的个数为 ( )个。A. 1 B. 2 C. 3 D. 55. 假定 p 是具有 int*类型的指针变量,则给 p 赋值的正确语句为( ) 。A. p=new
2、 int; B. p=new int10;C. p=new int*; D. p=new int*;6假定一个二维数组的定义语句为“int a34=3,4,2,8,6;”,则元素 a21的值为( ) 。A. 2 B. 4 C. 6 D. 07. 假定一个类的构造函数为“A(int aa=1, int bb=0) a=aa; b=bb;”,则执行“A x(0);”语句后,x.a 和 x.b 的值分别为( )。A. 0 和 0 B. 0 和 1 C. 1 和 0 D. 1 和 18. 假定 AA 为一个类,int a()为该类的一个成员函数,若该成员函数在类定义体外定义,则函数头为( ) 。Ain
3、t AA:a() Bint AA:a() CAA:a() DAA:int a()9关于插入运算符class AA int a10;int n;public:void SetA(int aa, int nn); /初始化函数int MaxA(); /从数组 a 中前 n 个元素中查找最大值void SortA(); /采用选择排序的方法对数组 a 中前 n 个元素 进行从小到大排序;该类中 MaxA()函数的实现如下,请在标号位置补充适当的内容。int _(1)_ int x=a0;for(int i=1; ix) _(2)_;_(3)_;(1) (2) (3)2. 类 A 的定义class A
4、 int *a; int n; int MaxLen;public:A(): a(0), n(0), MaxLen(0) /无参构造函数A(int *aa, int nn, int MM) /带参构造函数n=nn;MaxLen=MM;if(nMaxLen) exit(1);a=new intMaxLen;for(int i=0; idouble f1(int n) double sign=1,s=1;for(int i=2;ia;coutvoid f2(int& x, int& y)int z=x; x=y; y=z;void f3(int* x, int* y)int z=*x; *x=*y
5、; *y=z;void main()int x=10,y=26;coutx,y=x, yendl;f2(x,y);coutx,y=x, yendl;f3(coutx,y=x, yendl;x+; y-;f2(y,x);coutx,y=x, yendl;运行结果:五、程序改错,请根据程序段或函数模块的功能改写个别地方的错误。下面是分数类 fract 的定义及测试主程序,在类定义及其友元函数定义中有两处错误,更正错误后程序应显示41/28,请指出错误所在行的行号并给出改正意见。class fractint den; /分子int num; /分母public: fract(int d=0,int
6、n=1):den(d),num(n) /1 行friend fract /2 行void show() coutden/num; /3 行; /4 行 friend fract &operator+=(fract f1,fract f2) /5 行 /7 行f1.den=f1.den*f2.num+f1.num*f2.den; /8 行f1.num*=f2.num; /9 行return f1; /10 行void main()fract fr(3,4);fr+=fract(5,7);fr.show();错误行的行号为_和_。 (2 分)分别改正为_(4 分)和_(4 分)参考答案:一、单选题
7、1. B 2. B 3.A 4.C 5. D 6. D 7. A 8.A 9. B 10. C二、填空题1. void 2. x 3.contiune 4. 4 5. 不会6. ple 7. 多继承(或多重继承) 8. 类型 9. 不会 10. 2三、程序填充题,根据题意在横线上填写合适的内容。评分标准:每空 4 分1. (1) AA:MaxA() (2) x=ai (3) return x2. (1)ai=aai (2)delete a3. (1) Base:output() (2) Base(m1,m2) (3) mem3=m3四、理解问答题,写出程序运行结果或程序(或函数)所能实现的功能
8、。1. 计算并输出 1+ 的值,其中 a 的值由键盘输入。aii2)1(2.实现 strcat 函数的功能,把 str2 所指字符串连接到 str1 所指字符串的后面,并返回 str1 指针。 3. x,y=10, 26 x,y=26, 10 x,y=10, 26 x,y=25, 11 五、程序改错,请根据程序段或函数模块的功能改写个别地方的错误。2 5 friend fract fract 请您删除一下内容,O(_)O 谢谢! 【Chinas 10 must-see animations】The Chinese animation industry has seen considerable
9、 growth in the last several years. It went through a golden age in the late 1970s and 1980s when successively brilliant animation work was produced. Here are 10 must-see classics from Chinas animation outpouring that are not to be missed. Lets recall these colorful images that brought the country gr
10、eat joy. Calabash Brothers Calabash Brothers (Chinese: 葫芦娃) is a Chinese animation TV series produced by Shanghai Animation Film Studio. In the 1980s the series was one of the most popular animations in China. It was released at a point when the Chinese animation industry was in a relatively downed
11、state compared to the rest of the international community. Still, the series was translated into 7 different languages. The episodes were produced with a vast amount of paper-cut animations. Black Cat Detective Black Cat Detective (Chinese: 黑猫警长 ) is a Chinese animation television series produced by
12、 the Shanghai Animation Film Studio. It is sometimes known as Mr. Black. The series was originally aired from 1984 to 1987. In June 2006, a rebroadcasting of the original series was announced. Critics bemoan the series violence, and lack of suitability for childrens education. Proponents of the show
13、 claim that it is merely for entertainment. Effendi Effendi, meaning sir and teacher in Turkish, is the respectful name for people who own wisdom and knowledge. The heros real name was Nasreddin. He was wise and witty and, more importantly, he had the courage to resist the exploitation of noblemen. He was also full of compassion and tried his best to help poor people. Adventure of Shuke and Beita【舒克与贝塔】 Adventure of Shuke and Beita (Chinese: 舒克和贝塔) is a classic animation by Zheng Yuanjie, who is known as King o