最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考

上传人:ji****72 文档编号:27382374 上传时间:2018-01-09 格式:DOC 页数:10 大小:89.50KB
返回 下载 相关 举报
最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考_第1页
第1页 / 共10页
最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考_第2页
第2页 / 共10页
最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考_第3页
第3页 / 共10页
最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考_第4页
第4页 / 共10页
最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考》由会员分享,可在线阅读,更多相关《最新2016年电大开放教育C++语言程序设计期末考试试题及答案小抄参考(10页珍藏版)》请在金锄头文库上搜索。

1、专业好文档1C+语言程序设计 期末考试试题及答案姓名 _ 学号 _ 班号 _题 号 一 二(1) 二(2) 三 总 分成 绩一、填空1在类中必须声明成员函数的 原型 ,成员函数的 实现 部分可以写在类外。2如果需要在被调函数运行期间,改变主调函数中实参变量的值,则函数的形参应该是 引用 类型或 指针 类型。3 抽象 类只能作为基类使用,而不能声明它的对象。4进行函数重载时,被重载的同名函数如果都没有用 const 修饰,则它们的形参 个数 或 类型 必须不同。5通过一个 常 对象只能调用它的常成员函数,不能调用其他成员函数。6函数的递归调用是指函数直接或间接地调用 自身 。7拷贝构造函数的形参

2、必须是 本类对象的引用 。二、阅读下列程序,写出其运行时的输出结果如果程序运行时会出现错误,请简要描述错误原因。1请在以下两题中任选一题,该题得分即为本小题得分。如两题都答,则取两题得分之平均值为本小题得分。(1)程序:#include #include class Base private:char msg30;protected:int n;public:Base(char s,int m=0):n(m) strcpy(msg,s);void output(void) coutclass Samppublic:void Setij(int a,int b)i=a,j=b;Samp() co

3、ut#include class Vectorpublic:Vector(int s=100);intvoid Display(void);void Set(void);Vector(void);protected:int size;int *buffer;Vector:Vector(int s)buffer=new intsize=s;int& Vector:Elem(int ndx)if(ndx=size)coutclass CATpublic:CAT();CAT(const CAT();int GetAge() return *itsAge; void SetAge( int age )

4、 *itsAge=age; protected:int * itsAge;CAT:CAT()itsAge=new int;*itsAge=5;CAT:CAT()delete itsAge;itsAge=NULL;int main()CAT a;cout#include /类定义部分template class Nodeprivate:Node *next; /指向后继节点的指针public:T data; /数据域Node (const T / 构造函数void InsertAfter(Node *p); /在本节点之后插入一个同类节点 pNode *DeleteAfter(void); /删

5、除本节点的后继节点,返回其地址Node *NextNode(void) const; / 获取后继节点的地址;template class LinkedListprivate:Node *front, *rear; / 表头和表尾指针Node *prevPtr, *currPtr; /记录表当前遍历位置的指针,由插入和删除操作更新int size; / 表中的元素个数int position; / 当前元素在表中的位置序号。由函数 Reset 使用Node *GetNode(const T/ 生成新节点,数据域为 item,指针域为 ptrNextvoid FreeNode(Node *p);

6、 /释放节点void CopyList(const LinkedList / 将链表 L 拷贝到当前表/(假设当前表为空)。被拷贝构造函数、 operator=调用public:专业好文档- 6 -LinkedList(void); / 构造函数LinkedList(const LinkedList /拷贝构造函数LinkedList(void); / 析构函数LinkedList/重载赋值运算符int ListSize(void) const; /返回链表中元素个数(size)int ListEmpty(void) const; /size 为 0 时返回 TRUE,否则返回 FALSEvo

7、id Reset(int pos = 0); /将指针 currPtr 移动到序号为 pos 的节点,/prevPtr 相应移动,position 记录当前节点的序号void Next(void); /使 prevPtr 和 currPtr 移动到下一个节点int EndOfList(void) const; / currPtr 等于 NULL 时返回 TRUE, 否则返回 FALSEint CurrentPosition(void) const; /返回数据成员 positionvoid InsertFront(const T /在表头插入一个数据域为 item 的节点void Insert

8、Rear(const T /在表尾添加一个数据域为 item 的节点void InsertAt(const T /在当前节点之前插入一个数据域为 item 的节点void InsertAfter(const T /在当前节点之后插入一个数据域为 item 的节点T DeleteFront(void); /删除头节点,释放节点空间,更新 prevPtr、currPtr 和 sizevoid DeleteAt(void); /删除当前节点,释放节点空间,更新 prevPtr、currPtr 和 sizeT / 返回对当前节点成员 data 的引用void ClearList(void); / 清空

9、链表:释放所有节点的内存空间。;/类实现部分略.template void MergeList(LinkedList* la, LinkedList* lb,LinkedList* lc)/合并链表 la 和 lb,构成新链表 lc。/函数结束后,程序的数据所占内存空间总数不因此函数的运行而增加。while ( !la-ListEmpty() &!lb-ListEmpty() if (la-Data()Data() lc-InsertRear(la-Data();la-DeleteAt();else lc-InsertRear(lb-Data();lb-DeleteAt();专业好文档- 7

10、-while ( !la-ListEmpty() ) lc-InsertRear(la-Data();la-DeleteAt();while ( !lb-ListEmpty() ) lc-InsertRear(lb-Data();lb-DeleteAt();int main() LinkedList la, lb, lc;int item, i;/读如数据建立链表 lafor (i=0;i item;la.InsertRear(item);la.Reset();/读如数据建立链表 lbfor (i=0;i item;lb.InsertRear(item);lb.Reset();MergeLis

11、t(/合并链表lc.Reset();/ 输出各节点数据,直到链表尾while(!lc.EndOfList()cout lc.Data() ;lc.Next(); / 使 currPtr 指向下一个节点cout endl;专业好文档- 8 -请您删除一下内容,O(_)O 谢谢!2016 年中央电大期末复习考试小抄大全,电大期末考试必备小抄,电大考试必过小抄Basketball can make a true claim to being the only major sport that is an American invention. From high school to the prof

12、essional level, basketball attracts a large following for live games as well as television coverage of events like the National Collegiate Athletic Association (NCAA) annual tournament and the National Basketball Association (NBA) and Womens National Basketball Association (WNBA) playoffs. And it ha

13、s also made American heroes out of its player and coach legends like Michael Jordan, Larry Bird, Earvin Magic Johnson, Sheryl Swoopes, and other great players. At the heart of the game is the playing space and the equipment. The space is a rectangular, indoor court. The principal pieces of equipment

14、 are the two elevated baskets, one at each end (in the long direction) of the court, and the basketball itself. The ball is spherical in shape and is inflated. Basket-balls range in size from 28.5-30 in (72-76 cm) in circumference, and in weight from 18-22 oz (510-624 g). For players below the high

15、school level, a smaller ball is used, but the ball in mens games measures 29.5- 30 in (75-76 cm) in circumference, and a womens ball is 28.5-29 in (72- 74 cm) in circumference. The covering of the ball is leather, rubber, composition, or synthetic, although leather covers only are dictated by rules for college play, unless the teams agree otherwise. Orange is the regulation color. At all levels of play, the home team provides the ball. Inflation of the ball is based on the h

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号