ImageVerifierCode 换一换
格式:DOC , 页数:28 ,大小:123.54KB ,
资源ID:2882056      下载积分:5 金币
验证码下载
登录下载
邮箱/手机:
验证码: 获取验证码
温馨提示:
支付成功后,系统会自动生成账号(用户名为邮箱或者手机号,密码是验证码),方便下次登录下载和查询订单;
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/2882056.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  
声明  |  会员权益     获赠5币     写作写作

1、填表:    下载求助     索取发票    退款申请
2、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
3、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
4、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
5、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前自行私信或留言给上传者【w****g】。
6、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
7、本文档遇到问题,请及时私信或留言给本站上传会员【w****g】,需本站解决可联系【 微信客服】、【 QQ客服】,若有其他问题请点击或扫码反馈【 服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【 版权申诉】”(推荐),意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:4008-655-100;投诉/维权电话:4009-655-100。

注意事项

本文(C程序设计实训总结报告.doc)为本站上传会员【w****g】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4008-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

C程序设计实训总结报告.doc

1、实训一:类和对象定义及使用实训目标:(1)掌握类和对象定义和使用方法,了解面向对象方法中经过对象间传输消息工作机制。(2)正确掌握类不一样属性组员使用方法。(3)掌握结构函数和析构函数概念,了解结构函数和析构函数实施过程。(4)掌握友元函数和友元类定义和使用。(5)基础掌握指针和引用作为函数参数应用。实训内容:定义一个时间类Time,有三个私有组员变量Hour、Minute、Second,定义结构函数、析构函数和用于改变、获取、输出时间信息公有函数,主函数中定义时间对象,并经过调用多种组员函数完成时间设定、改变、获取、输出等功效。 按要求完成类定义和实现。 修改数据组员访问方法,观察编译结果。

2、 在Time类中定义一个组员函数,用于实现时间增加一秒功效,主函数中经过对象调用该函数,并输出增加一秒后时间信息。 定义一个一般函数。void f(Time t) t. PrintTime( );在Time类中增加拷贝结构函数定义,主函数中调用该函数,利用调试工具跟踪,分析整个程序调用结构函数(包含拷贝结构函数)和析构函数次数;再将f函数形式参数分别修改为引用参数和指针参数(此时函数代码修改为t- PrintTime( );,主函数中调用,再分析此时调用结构函数和析构函数次数。实训代码:#includeusing namespace std;class Timeprivate:int Hour

3、,Minute,Second;public:Time(int h=0,int m=0,int s=0);Time(const Time &ob);Time();void ChangeTime(int h,int m,int s);int GetHour();int GetMinute();int GetSecond();void PrintTime();void IncreaseOneSecond();Time:Time(int h,int m,int s) Hour=h; Minute=m; Second=s;Time:Time(const Time &ob) Hour=ob.Hour; M

4、inute=ob.Minute; Second=ob.Second;Time:Time()void Time:ChangeTime(int h,int m,int s) Hour=h; Minute=m; Second=s;int Time:GetHour() return Hour;int Time:GetMinute() return Minute;int Time:GetSecond() return Second;void Time:PrintTime() coutHour: Minute: Secondendl;void Time:IncreaseOneSecond() Second

5、+;/*void Time:f(Time t) t.PrintTime(); coutcall fn;*/int main() Time a; Time b(13); Time c(13,15); Time d(13,15,45); a.PrintTime(); b.PrintTime(); c.PrintTime(); d.PrintTime(); a.ChangeTime(12,15,45); b.ChangeTime(12,15,45); c.ChangeTime(12,15,45); d.ChangeTime(12,15,45); couta.GetHour():a.GetMinute

6、():a.GetSecond()endl; coutb.GetHour():b.GetMinute():b.GetSecond()endl; coutc.GetHour():c.GetMinute():c.GetSecond()endl; coutd.GetHour():d.GetMinute():d.GetSecond()endl; return 0;程序运行结果实训小结:结构函数和析构函数调用方法及实施次序是:先是结构函数然后是析构函数。调用方法是自动调用,实施次序是先实施结构函数,待程序结束时再实施析构函数。 实训二:个人银行账户管理程序类设计实训目标:掌握面向对象中类、继承、多态性开发

7、思想;掌握流概念; 独立设计个人银行账户管理程序。实训内容:1、 个人银行账户管理程序类关系图2、 个人银行账户管理程序个人账户设置和应用3、 个人银行账户管理程序实训代码:1、 个人银行账户管理程序类设计class account private: std:string id; double balance; static double total; protected: account(const Date &date,const std:string &id); void record(const Date &date,double amount,const std:string &de

8、sc); void error(const std:string &msg) const; public: const std:string &getId() const return id; double getBalance() const return balance; static double gettotal() return total; void show() const; ; class SavingsAccount:public account private: accumulator acc; double rate; public: SavingsAccount(con

9、st Date &date,const std:string &id,double rate); double getrate() const return rate; void deposit(const Date &date,double amount,const std:string &desc); void withdraw(const Date &date,double amount,const std:string &desc); void settle(const Date &date); ; class creditaccount:public account private:

10、 accumulator acc; double credit; double rate; double fee; double getdebt() const double balance=getBalance(); return (balance0 ? balance : 0); public: creditaccount(const Date &date,const std:string &id,double credit,double rate,double fee); double getcredit() const return credit; double getrate() c

11、onst return rate; double getfee() const return fee; double getavailablecredit() const if (getBalance()value=value; void reset(const Date &date,double value) lastdate=date;this-value=value;sum=0; ;class Date private: int year; int month; int day; int totaldays; public: Date(int year,int month,int day

12、); int getyear() const return year; double getmonth() const return month; int getday() const return day; int getmaxday() const; bool isleapyear() const return year%4=0 & year%100!=0 | year%400=0; void show() const; int distance (const Date& date) const return totaldays-date.totaldays; ;2、 个人银行账户管理程序

13、类关系图3、 个人银行账户管理程序个人账户设置和应用SavingsAccount wutingming(date,0.015); creditaccount wutingmin(date,0.0005,50);wutingming.deposit(Date(,11,5),1000,buy book);wutingmin.withdraw(Date(,11,5),buy MP3);wutingming.settle(Date(,12,5);wutingmin.settle(Date(,12,5);wutingming.show();coutendl;wutingmin.show();couten

14、dl;4、 个人银行账户管理程序关键代码#include account.h#includeusing namespace std;int main()Date date(,11,1); SavingsAccount sa1(date,03755217,0.015);SavingsAccount sa2(date,02342342,0.015);SavingsAccount wutingming(date,0.015);creditaccount ca(date,C5392394,10000,0.0005,50);creditaccount wutingmin(date,0.0005,50);

15、sa1.deposit(Date(,11,5),5000,salary);sa2.deposit(Date(,11,25),10000,sell stock 0323);wutingming.deposit(Date(,11,5),1000,buy book);wutingmin.withdraw(Date(,11,5),buy MP3);ca.withdraw(Date(,11,15),buy a cell);ca.settle(Date(,12,1);ca.deposit(Date(,12,1),repay the credit);sa1.deposit(Date(,12,5),5500,

16、salary);sa1.settle(Date(,1,1);sa2.settle(Date(,1,1); wutingming.settle(Date(,12,5);wutingmin.settle(Date(,12,5);ca.settle(Date(,12,1); coutendl;sa1.show();coutendl;sa2.show();coutendl;wutingming.show();coutendl;wutingmin.show();coutendl;ca.show();coutendl;couttotal: account:gettotal()endl;return 0;

17、#include account.h#includeusing namespace std;int main()Date date(,11,1); SavingsAccount sa1(date,s3755217,0.015);SavingsAccount sa2(date,02342342,0.015);SavingsAccount wutingming(date,0.015);creditaccount ca(date,C5392394,10000,0.0005,50);account*accounts=&sa1,&sa2,&wutingming,&ca;const int n=sizeo

18、f(accounts)/sizeof(account *);cout(d)deposit (w)withdraw (s)show (c)chang day (n)next month (e)exitendl;char cmd;do date.show();coutttotal: account:gettotal()endl;cout;int index,day,i;double amount;string desc;cincmd;switch (cmd)case d:cinindexamount;getline(cin,desc);accountsindex-deposit(date,amou

19、nt,desc); break;case w:cinindexamount;getline(cin,desc);accountsindex-withdraw(date,amount,desc); break;case s:for (i=0;in;i+)coutishow();coutday;if (daydate.getday()coutdate.getmaxday()coutinvalid day;else date=Date(date.getyear(),date.getmonth(),day); break;case n:if(date.getmonth()=12)date=Date(d

20、ate.getyear()+1,1,1);else date=Date(date.getyear(),date.getmonth()+1,1);for(i=0;isettle(date); break; while (cmd!=e); return 0;程序运行结果实训小结:经过本实训,应用虚函数和抽象类对程序进行改善:1) 将show函数申明为虚函数,所以经过指向creditaccount类实例account类型指针来调用show函数时,被实际调用将是creditaccount类定义show函数。这么,假如创建一个account指针类型数组,使各个元素分别指向各个账户对象,就能够经过一个循环

21、来调用它们show函数。2)在account类中添加deposit,withdraw,settle这3个函数申明,且将它们全部申明为纯虚函数,这使得经过基类指针能够调用派生类对应函数,而且无须给出它们在基类中实现。经过这一改动以后,account类就变成了抽象类。实训三、图书信息管理系统主界面实训目标:能够很好完成程序主体设计,界面友好,功效齐全;程序思绪清楚易懂,能够充足利用所学工具实现各项操作。独立力完成实训汇报,内容充实、见解明确、新奇。实训内容:图书信息管理系统,使之能提供以下功效:1、 系统以菜单方法工作。2、 借书3、 还书4、 图书维护5、 读者维护6、 退出:包含返回主界面和退

22、出系统等功效。实训代码:#include#include#include#includestruct books_list char author20; /*作者名*/ char bookname20; /*书名*/ char publisher20; /*出版单位*/ char pbtime15; /*出版时间*/ char loginnum10; /*登陆号*/ float price; /*价格*/ char classfy10; /*分类号*/ struct books_list * next; /*链表指针域*/; struct books_list * Create_Books_D

23、oc(); /*新建链表*/void InsertDoc(struct books_list * head); /*插入*/void DeleteDoc(struct books_list * head , int num);/*删除*/void Print_Book_Doc(struct books_list * head);/*浏览*/void search_book(struct books_list * head); /*查询*/void info_change(struct books_list * head);/*修改*/void save(struct books_list *

24、head);/*保留数据至文件*/*新建链表头节点*/struct books_list * Create_Books_Doc() struct books_list * head; head=(struct books_list *)malloc(sizeof(struct books_list); /*分配头节点空间*/ head-next=NULL; /*头节点指针域初始化,定为空*/ return head; /*保留数据至文件*/void save(struct books_list * head) struct books_list *p; FILE *fp; p=head; fp

25、=fopen(data.txt,w+); /*以写方法新建并打开 data.txt文件*/ fprintf(fp,n); /*向文件输出表格*/ fprintf(fp,登录号 书 名 作 者 出版单位 出版时间 分类号 价格 n); fprintf(fp,n); /*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/ while(p-next!= NULL) p=p-next; fprintf(fp,%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n,p-loginnum,p-bookname,p-author,p-publisher,p

26、-pbtime,p-classfy,p-price); fprintf(fp,n); fclose(fp); printf( 已将图书数据保留到 data.txt 文件n);/*插入*/void InsertDoc(struct books_list *head) /*定义结构体指针变量 s指向开辟新结点首地址 p为中间变量*/ struct books_list *s, *p; char flag=Y; /*定义flag,方便用户选择反复输入*/ p=head; /*遍历到尾结点,p指向尾结点*/ while(p-next!= NULL) p=p-next; /*开辟新空间,存入数据,添加进

27、链表*/ while(flag=Y|flag=y) s=(struct books_list *)malloc(sizeof(struct books_list); printf(n 请输入图书登陆号:); fflush(stdin); scanf(%s,s-loginnum); printf(n 请输入图书书名:); fflush(stdin); scanf(%s,s-bookname); printf(n 请输入图书作者名:); fflush(stdin); scanf(%s,s-author); printf(n 请输入图书出版社:); fflush(stdin); scanf(%s,s

28、-publisher); printf(n 请输入图书出版时间:); fflush(stdin); scanf(%s,s-pbtime); printf(n 请输入图书分类号:); fflush(stdin); scanf(%s,s-classfy); printf(n 请输入图书价格:); fflush(stdin); scanf(%f,&s-price); printf(n); p-next=s; /*将新增加节点添加进链表*/ p=s; /*p指向尾节点,向后移*/ s-next=NULL; printf( 添加成功!); printf(n 继续添加?(Y/N):); fflush(st

29、din); scanf(%c,&flag); printf(n); if(flag=N|flag=n) if(flag=Y|flag=y); save(head); /*保留数据至文件*/ return;/*查询操作*/void search_book(struct books_list *head) struct books_list * p; char temp20; p=head; if(head=NULL | head-next=NULL) /*判定数据库是否为空*/ printf( 图书库为空!n); else printf(请输入您要查找书名: ); fflush(stdin);

30、scanf(%s,temp); /*指针从头节点开始移动,遍历至尾结点,查找书目信息*/ while(p-next!= NULL) p=p-next; if(strcmp(p-bookname,temp)=0) printf(n图书已找到!n); printf(n); printf(登录号: %stn,p-loginnum); printf(书名: %stn,p-bookname); printf(作者名: %stn,p-author); printf(出版单位: %stn,p-publisher); printf(出版时间: %stn,p-pbtime); printf(分类号: %stn,

31、p-classfy); printf(价格: %.2ftn,p-price); if(p-next=NULL) printf(n查询完成!n); return; /*浏览操作*/ void Print_Book_Doc(struct books_list * head) struct books_list * p; if(head=NULL | head-next=NULL) /*判定数据库是否为空*/ printf(n 没有图书统计! nn); return; p=head; printf(n); printf(登录号 书 名 作 者 出版单位 出版时间 分类号 价格 n); printf(

32、n); /*指针从头节点开始移动,遍历至尾结点,依次输出图书信息*/ while(p-next!= NULL) p=p-next; printf(%-6.6s%-10.10s%-10.10s%-10.10s%-12.12s%-6.6s%.2f n,p-loginnum,p-bookname,p-author,p-publisher,p-pbtime,p-classfy,p-price); /*循环输出表格*/ printf(n); printf(n); /*修改操作*/void info_change(struct books_list * head) struct books_list *

33、p; int panduan=0; /*此变量用于判定是否找到书目*/ char temp20; p=head; printf(请输入要修改书名:); scanf(%s,temp); while(p-next!= NULL) p=p-next; if(strcmp(p-bookname,temp)=0) printf(n 请输入图书登陆卡号:); fflush(stdin); scanf(%s,p-loginnum); printf(n 请输入图书书名:); fflush(stdin); scanf(%s,p-bookname); printf(n 请输入图书作者名:); fflush(std

34、in); scanf(%s,p-author); printf(n 请输入图书出版社:); fflush(stdin); scanf(%s,p-publisher); printf(n 请输入图书出版时间:); fflush(stdin); scanf(%s,p-pbtime); printf(n 请输入图书分类号:); fflush(stdin); scanf(%s,p-classfy); printf(n 请输入图书价格:); fflush(stdin); scanf(%f,&p-price); printf(n); panduan=1; if(panduan=0) printf(n 没有

35、图书统计! nn); return;/*删除操作*/void DeleteDoc(struct books_list * head) struct books_list *s,*p; /*s为中间变量,p为遍历时使用指针*/ char temp20; int panduan; /*此变量用于判定是否找到了书目*/ panduan=0; p=s=head; printf( 请输入您要删除书名:); scanf(%s,temp); /*遍历到尾结点*/ while(p!= NULL) if(strcmp(p-bookname,temp)=0) panduan+; break; p=p-next; if(panduan=1) for(;s-next!=p;) /*找到所需删除卡号结点上一个结点*/ s=s-next; s-next=p-next; /*将后一节点地址赋值给前一节点指针域*/ free(p); printf(n 删除成功! n); else /*未找到对应书目*/ printf( 您输入书目不存在,请确定后输入!n); return;int main(void) struct books_list * head; char choice; head=NULL; for(;) /*实现反复输入选择*/ printf(

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        获赠5币

©2010-2024 宁波自信网络信息技术有限公司  版权所有

客服电话:4008-655-100  投诉/维权电话:4009-655-100

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :gzh.png    weibo.png    LOFTER.png 

客服