电大C++语言程序设计期末复习题资料小抄【含答案】 .doc

上传人:仙人指路1688 文档编号:2199874 上传时间:2023-01-29 格式:DOC 页数:11 大小:73.01KB
返回 下载 相关 举报
电大C++语言程序设计期末复习题资料小抄【含答案】 .doc_第1页
第1页 / 共11页
电大C++语言程序设计期末复习题资料小抄【含答案】 .doc_第2页
第2页 / 共11页
电大C++语言程序设计期末复习题资料小抄【含答案】 .doc_第3页
第3页 / 共11页
电大C++语言程序设计期末复习题资料小抄【含答案】 .doc_第4页
第4页 / 共11页
电大C++语言程序设计期末复习题资料小抄【含答案】 .doc_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《电大C++语言程序设计期末复习题资料小抄【含答案】 .doc》由会员分享,可在线阅读,更多相关《电大C++语言程序设计期末复习题资料小抄【含答案】 .doc(11页珍藏版)》请在三一办公上搜索。

1、电大C+语言程序设计期末复习题及答案小抄资料一、单项选择题1、 面向对象程序设计数据与_放在一起,作为一个相互依存、不可分割的整体来处理。A、对数据的操作B、信息C、数据隐藏D、数据抽象2、 已知:int a=1,b=2,c=3,d=4,则表达式ab?a:cd?c:d 的值为_。A、1B、2C、3D、43、下列while循环的次数是_。while( int i=0 ) i- -;A、0B、1C、5D、无限4、以下程序的输出结果是_。#include fuc( char* s) char* p=s; while( *p) p+; return (p-s);main() coutfuc(ABCDE

2、F); A、3B、6C、8D、05、_的功能是对对象进行初始化。A、析构函数B、数据成员C、构造函数D、静态成员函数6、下列引用的定义中,_是错误的。A、int i;B、int i;C、float i;D、char d;int& j=i; int &j; float& j=i;j=i; char &k=d;7、若类A和类B的定义如下:class A int i,j;public: void get(); /.;class B:public A int k;public: make(); /.;void B:make() k=i*j;则上述定义中,_是非法的表达式。A、void get();B、

3、int k;C、void make();D、k=i*j;8、以下程序段_。int x = -1;do x = x*x;while( !x );A、是死循环B、循环执行2次C、循环执行1次D、有语法错误9、对定义重载函数的下列要求中,_是错误的。A、要求参数的个数不同B、要求参数中至少有一个类型不同C、要求参数个数相同时,参数类型不同D、要求函数的返回值不同10、一个_允许用户为类定义一种模式,使得类中的某些数据成员及某些成员函数的返回值能取任意类型。A、函数模板B、模板函数C、类模板D、模板类(Key:1-5:AAABC6-10:BDCDC)二、填空题1、在C+类中可以包含 、 和 三种具有不

4、同访问控制权的成员。(Key:公有或public,保护或protected,私有或private)2、以下程序的执行结果是_。#include void func( int );void func( double );void main( ) double a=88.18; func(a); int b=97; func(b); void func( int x ) coutxendl;void func( double x ) coutx,;(Key: 88.18,97)3、类中的数据和成员函数默认访问类型为_。(Key:私有或private)4、以下程序的执行结果是_。#include u

5、sing namespace std;f(int b,int n)int i,r=1;for( i=0;i=n;i+ )r=r*bi;return r;int _tmain()int x,a = 2,3,4,5,6,7,8,9;x=f(a,3);coutx=xendl;return 0;(Key: x=120)5、在类内部定义的_数据不能被不属于该类的函数来存取,定义为_的数据则可以在类外部进行存取。(Key:private或 私有 或 protected 或 保护;public 或 公有)6、下列程序输出的结果是_。#include using namespace std;void sub(

6、 char a,char b )char c=a;a=b;b=c;void sub( char* a,char b )char c=*a;*a=b;b=c;void sub( char* a,char* b )char c=*a;*a=*b;*b=c;int _tmain() char a=A,b=B;sub(&a,&b);coutabendl;return 0;(Key: BA)7、下列程序输出的结果是_。#include using namespace std;void Exchange( int* pFirst,int* pLast )if( pFirstpLast )int Chang

7、e = *pFirst;*pFirst = *pLast;*pLast = Change;Exchange(+pFirst,-pLast);void Print( int Integer,int HowMany)for( int Index=0; IndexHowMany; Index+ )coutIntegerIndex ;coutendl;int _tmain()int Integer = 1,2,3,4;Exchange(&Integer0,&Integer3);Print(Integer,4);return 0;(Key: 4 3 2 1)8、下列程序输出的结果是_。#include

8、using namespace std;int _tmain()int nInteger = 5, &rInteger = nInteger;rInteger = nInteger+1;coutnInteger,rIntegerendl;return 0;(Key: 6,6)9、_是一种特殊的成员函数,它主要用来为对象分配内存空间,对类的数据成员进行初始化并进行对象的其他内部管理操作。(构造函数)10、下列程序输出的结果是_。#include using namespace std;int _tmain()int x=2,y=3,z=4;cout( xy ) & ( !z ) | (x*y)

9、)endl;return 0;(Key:1)三、程序分析:给出程序运行后的输出结果(每小题5分,共20分)1、#include using namespace std;int _tmain() int x=1,y=2,z=3; x+=y+=z; cout(xy?y:x),; cout(xy?x+:y+),; coutyendl; return 0;Key: 6,5,6 2、#include using namespace std;void func( int b );void main() int a = 5,6,7,8 ,i; func(a); for( i=0;i4;i+ ) coutai

10、 ;void func( int b ) int j; for( j=0;j4;j+ ) bj = 2*j;Key: 0 2 4 63、#include using namespace std;class CSampleint i;public:CSample(void);CSample(void);CSample(int val);void Print(void);CSample:CSample(void)coutConstructor1endl;i=0;CSample:CSample(int val)coutConstructor2endl;i=val;void CSample:Print

11、(void)couti=iendl;CSample:CSample(void)coutDestructorendl;int _tmain() CSample a,b(10);a.Print();b.Print();return 0;Key: Constructor1Constructor2i=0i=10DestructorDestructor4、#include using namespace std;class CDataprotected:int nInteger;public:CData( int Integer );CData( void );void Print(void);CDat

12、a:CData( int Integer ): nInteger(Integer)coutConstructing a dataendl;CData:CData( void )coutDestructing a dataendl;void CData:Print(void)coutThe data is nIntegerendl;class CNumber :public CDataprotected:double fNumber;public:CNumber(int Integer,double Number);CNumber(void);void Print(void);CNumber:C

13、Number( int Integer,double Number ): CData( Integer ), fNumber(Number)coutConstructing a numberendl;CNumber:CNumber( void )coutDestructing a numberendl;void CNumber:Print(void)CData:Print();coutThe number is fNumberendl;int _tmain()CNumber Number(1,3.8);Number.Print();return 0;Key: Constructing a da

14、taConstructing a numberThe data is 1The number is 3.8Destructing a numberDestructing a data四、根据要求完成程序1、完成以下程序,求1!+2!+3!+4!+5!+6!+7!+8!+9!+10!之和。#include using namespace std;int _tmain() long Term=_ ,Sum=_;for( int Index=1;Index=_;Index+)Term *=_;Sum +=_;coutSum of factorial from 1 to 10 is ; coutSum

15、endl;return 0; Key:1 0 10 Index Term2、完成下面程序,计算三角形和正方形的面积。设三角形和正方形的宽为fWidth,高为fHeight,则三角形的面积为fWidth*fHeigth/2。#include using namespace std;class CShapepublic:CSquare:CSquare(double Width,double Height):_double CSquare:Area(void)_;int _tmain() CTriangle Triangle(16,8); coutThe area of triangle is Tr

16、iangle.Area()endl; CSquare Square(13,8); coutThe area of square is Square.Area()endl; return 0; Key: fWidth(Width) CShape(Width,Height) return fWidth*fHeight/2 CShape(Width,Height) return fWidth*fHeight五、用面向对象方法设计一个阶乘类CFactorial,在CFactorial类的构造函数CFactorial(long Integer)中,将Integer的值赋给nInteger;在主函数int

17、 _tmain(),键盘输入任一整数Integer,以Integer的值为实际参数构造一个阶乘对象Factorial,调用对象Factorial的相应成员函数输出nInteger的阶乘值fFactorial。完成以下函数的代码设计:(1)、设计构造函数CFactorial(long Integer),求出nInteger的阶乘值fFactorial。若nInteger没有阶乘值,则fFactorial赋值为0。(2)、设计CFactorial类的成员函数void Print(void),输出nInteger的阶乘值fFactorial。若nInteger没有阶乘,则输出nInteger没有阶乘

18、的信息。#include using namespace std;class CFactorialpublic:CFactorial(long Integer);protected:long nInteger;float fFactorial;public:void Print(void);CFactorial:CFactorial(long Integer) : nInteger(Integer)/作答处void CFactorial:Print(void)/作答处int _tmain()long Integer;coutInteger; CFactorial Factorial(Integ

19、er);Factorial.Print();return 0; Key: 解:参考程序:#include using namespace std;class CFactorialpublic:CFactorial(long Integer);protected:long nInteger;float fFactorial;public:void Print(void);CFactorial:CFactorial(long Integer) : nInteger(Integer)if( nInteger1 ) /1分fFactorial*=Integer; /1分Integer-; /1分voi

20、d CFactorial:Print(void)if( fFactorial ) /0.5分coutThe factorial of nInteger is fFactorialendl; /1分else /0.5分coutThere is not any factorial for nIntegerendl;/1分int _tmain()long Integer;coutInteger; CFactorial Factorial(Integer);Factorial.Print();return 0; 请您删除一下内容,O(_)O谢谢!【Chinas 10 must-see animatio

21、ns】The Chinese animation industry has seen considerable 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 r

22、ecall these colorful images that brought the country great joy. Calabash Brothers Calabash Brothers (Chinese: 葫芦娃) is a Chinese animation TV series produced byShanghaiAnimationFilmStudio. In the 1980s the series was one of the most popular animations in China. It was released at a point when the Chi

23、nese animation industry was in a relatively downed 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

24、 a Chinese animation television series produced by 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 suitabili

25、ty for childrens education. Proponents of the show claim that it is merely for entertainment. Effendi Effendi, meaning sir andteacher 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

26、 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 of Fairy Tales in China. Shuke and B

27、eita are two mice who dont want to steal food like other mice. Shuke became a pilot and Beita became a tank driver, and the pair met accidentally and became good friends. Then they befriended a boy named Pipilu. With the help of PiPilu, they co-founded an airline named Shuke Beita Airlines to help o

28、ther animals. Although there are only 13 episodes in this series, the content is very compact and attractive. The animation shows the preciousness of friendship and how people should be brave when facing difficulties. Even adults recalling this animation today can still feel touched by some scenes.

29、Secrets of the Heavenly Book Secrets of the Heavenly Book, (Chinese: 天书奇谈)also referred to as Legend of the Sealed Book or Tales about the Heavenly Book, was released in 1983. The film was produced with rigorous dubbing and fluid combination of music and vivid animations. The story is based on the c

30、lassic literature Ping Yao Zhuan, meaning The Suppression of the Demons by Feng Menglong. Yuangong, the deacon, opened the shrine and exposed the holy book to the human world. He carved the books contents on the stone wall of a white cloud cave in the mountains. He was then punished with guarding th

31、e book for life by the jade emperor for breaking heavens law. In order to pass this holy book to human beings, he would have to get by the antagonist fox. The whole animation is characterized by charming Chinesepainting, including pavilions, ancient architecture, rippling streams and crowded markets

32、, which fully demonstrate the unique beauty of Chinas natural scenery. Pleasant Goat and Big Big Wolf【喜洋洋与灰太狼】 Pleasant Goat and Big Big Wolf (Chinese:喜羊羊与灰太狼) is a Chinese animated television series. The show is about a group of goats living on the Green Pasture, and the story revolves around a clu

33、msy wolf who wants to eat them. It is a popular domestic animation series and has been adapted intomovies. Nezha Conquers the Dragon King(Chinese: 哪吒闹海)is an outstanding animation issued by the Ministry of Culture in 1979 and is based on an episode from the Chinese mythological novel Fengshen Yanyi.

34、 A mother gave birth to a ball of flesh shaped like a lotus bud. The father, Li Jing, chopped open the ball, and beautiful boy, Nezha, sprung out. One day, when Nezha was seven years old, he went to the nearby seashore for a swim and killed the third son of the Dragon King who was persecuting local

35、residents. The story primarily revolves around the Dragon Kings feud with Nezha over his sons death. Through bravery and wit, Nezha finally broke into the underwater palace and successfully defeated him. The film shows various kinds of attractive sceneries and the traditional culture of China, such

36、as spectacular mountains, elegant sea waves and exquisite ancient Chinese clothes. It has received a variety of awards. Havoc in Heaven The story of Havoc in Heaven(Chinese: 大闹天宫)is based on the earliest chapters of the classic storyJourney to the West. The main character is Sun Wukong, aka the Monk

37、ey King, who rebels against the Jade Emperor of heaven. The stylized animation and drums and percussion accompaniment used in this film are heavily influenced byBeijingOpera traditions. The name of the movie became a colloquialism in the Chinese language to describe someone making a mess. Regardless

38、 that it was an animated film, it still became one of the most influential films in all of Asia. Countless cartoon adaptations that followed have reused the same classic story Journey to the West, yet many consider this 1964 iteration to be the most original, fitting and memorable, The Golden Monkey

39、 Defeats a Demon【金猴降妖】 The Golden Monkey Defeats a Demon (Chinese: 金猴降妖), also referred as The Monkey King Conquers the Demon, is adapted from chapters of the Chinese classics Journey to the West, or Monkey in the Western world. The five-episode animation series tells the story of Monkey King Sun Wu

40、kong, who followed Monk Xuan Zangs trip to the West to take the Buddhistic sutra. They met a white bone evil, and the evil transformed human appearances three times to seduce the monk. Twice Monkey King recognized it and brought it down. The monk was unable to recognize the monster and expelled Sun Wukong. Xuan Zang was then captured by the monster. Fortunately Bajie, another apprentice of Xuan Zang, escaped and persuaded the Monkey King to come rescue the monk. Finally, Sun kills the

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

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


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号