ImageVerifierCode 换一换
格式:DOC , 页数:14 ,大小:95.50KB ,
资源ID:2702543      下载积分:20 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.docduoduo.com/d-2702543.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录   微博登录 

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(面向对象程序设计试卷A答案及评分标准.doc)为本站会员(dzzj200808)主动上传,道客多多仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知道客多多(发送邮件至docduoduo@163.com或直接QQ联系客服),我们立即给予删除!

面向对象程序设计试卷A答案及评分标准.doc

1、面向对象程序设计试卷 A 答案及评分标准本试卷共 10 个题,分别按以下标准评分,最后根据整个答题的情况,从程序设计风格的角度给予 0-5 分的附加分。1、编写程序,将从键盘读入的所有大小写字母写入名为 a.txt 的文件中(遇 EOF 结束) 。(本题总分 10 分,fopen 函数使用妥当 4 分,读入过程正确 4 分,关闭文件 2 分。程序结构完整,有不妥之处,酌情扣分。 )#include main ( )FILE *fptr;fptr = fopen(“a.txt“,“w“);if (fptr=NULL)return 0;char a;a=getchar( );while(a!=EO

2、F )if(a=a void setWidth(int w);void setLength(int l); private:int Length;int Width;int Rectangle:getArea()return Length*Width;void Rectangle:setLength(int l)Length=l;void Rectangle:setWidth(int w)Width=w;main()int len,wid;Rectangle r1;coutlen;coutwid;r1.setLength(len);r1.setWidth(wid);cout#include s

3、truct Node int item;struct Node *next;class IStack public:IStack();IStack();void push(int item);int pop();int getItemNum();private:Node *head;int size;IStack:IStack()head = NULL;size = 0;IStack:IStack()Node *temp = head;while (temp != NULL) temp = head-next; delete head;head = temp;void IStack:push(

4、int item)Node *temp = new Node;temp-item = item;temp-next = head;head = temp;size+;int IStack:pop()if (size = 0) coutnext;int i = temp-item;delete temp;return i;int IStack:getItemNum() return size;main() IStack istack;istack .push(6);istack .push(7);istack .push(8);cout#include class Rationalpublic:

5、Rational(int num1=1,int num2=1);Rational operator*(Rational r1);void showNomal();private:int up;int down;int Minmultiple(int a,int b); /最小公倍数int Maxdivisor(int a,int b);/最大公约数;Rational:Rational(int num1,int num2)up=num1;down=(num2=0)?1:num2;int i;i=Maxdivisor(up,down);up=up/i;down=down/i;int Rationa

6、l:Maxdivisor(int a,int b)int temp;int remainder;if(aclass Time friend ostream public:Time(int h=0, int m=0, int s=0);private:int hour, minute, second;Time:Time(int h, int m, int s)hour=h;minute=m;second=s;ostream input t.hour a t.minute b t.second ;return input;int main()Time t;cout t;/调用自己定义的运算符重载函

7、数 operator(cin,t)cout #include class Circle:public Shapepublic:Circle(double xn,double yn,double rn) x=xn;y=yn;r=rn;double area()return 3.14*r*r;void show()coutint n=0;class shapevirtual double area() const=0; 虚函数friend addarea(shape ;int main()Circle a(1.0,1.0,1.0);Triagle b(1.0,1.0,1.0);Rectangle

8、c(1.0,1.0,1.0);shape * a1;shape * b1;shape * c1;a1=b1=c1=addarea(a1);addarea(b1);addarea(c1);couttemplate void change(Tname a,int n)Tnamen b=new namen+1;for(int i=0;in;i+)bi=an-i-1;a=b;delete b;int main()int a10;for(int i=0;i10;i+)ai=i;float b20;for(float n=0.0,n20;n+)bn=n;change(a,10);change(b,20);

9、for(int i=0;i10;i+)coutai“t“;for(i=0;i20;i+)coutbi“t“;return 0;10、编写一个用于英语单词学习的系统,按照如下步骤进行:(1) 编写类 Eword,类 Eword 的对象表示一个英文单词以及它的含义、应用示例;(2) 为类 Eword 添加显示对象信息的成员函数;(3) 为类 Eword 添加保存对象到文件以及从文件恢复对象的成员函数;(4) 编写类 WordList,以链表或数组的方式管理类 Eword 的多个对象;(5) 为类 WordList 添加查询一个单词的成员函数;(6) 为类 WordList 添加插入一个单词(类 E

10、word 的对象)的成员函数;(7) 为类 WordList 添加逐个显示英语单词的成员函数;(8) 编写程序利用上述两个类借助文件管理自己要学习的英语单词;(9) 对程序进行进一步的优化,如为已经记住的单词添加标记,下次不再显示等,使系统更加实用。(本题总分 10 分,第 1 小题至第 7 小题各一分,第 8 题 2 分,第 9 题 1 分。程序结构完整,有不妥之处,酌情扣分。 )class Eworld public Eword(char *a,char *hanyi,char *shili)word=new charstrlen(a)+1;strcpy(word,a);h=new cha

11、rstrlen(hanyi+1);strcpy(h,hanyi);s=new charstrlen(shiyi+1);strcpy(s,shili);void show() /显示单词及含义,示例coutwordendl;couthendl;coutsendl;void showwold() /显示单词coutwordendl;void save(ifstream void recovery(ofstream private:char *word;char *h;char *s;int flag;class WordListpublic:int add(Eword *a) /添加单词if(n=

12、nCount)return 0;else list+n=a;return 1;int find(char *a) /查找单词for(int i=0;in;i+)if(strcmp(Listi.word,a)=0)return i;return -1;void Lshow() /显示所有单词for(int i=0;in;i+)listi.showword();void Lshow2() /显示未记住的单词for(int i=0;in;i+)if(listi.flag!=1)listi.show();privateint nCount;int n;Eword list;WordList(int a) /初始化容量 nCount,已记录单词数 n; nCount=a;n=0;list=new Eworda;SetFlag(int n)flag=n;测试方法:先声明一个 WordList 对象,初始化容量,再添入单词,用 Setflag 标记单词或重新标记。

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报