西北工业大学C大作业第题

上传人:工**** 文档编号:569319600 上传时间:2024-07-28 格式:PDF 页数:13 大小:256.52KB
返回 下载 相关 举报
西北工业大学C大作业第题_第1页
第1页 / 共13页
西北工业大学C大作业第题_第2页
第2页 / 共13页
西北工业大学C大作业第题_第3页
第3页 / 共13页
西北工业大学C大作业第题_第4页
第4页 / 共13页
西北工业大学C大作业第题_第5页
第5页 / 共13页
点击查看更多>>
资源描述

《西北工业大学C大作业第题》由会员分享,可在线阅读,更多相关《西北工业大学C大作业第题(13页珍藏版)》请在金锄头文库上搜索。

1、作业名称:作业名称: 学生通讯录管理系统学学院:院: 自动化学院班班级:级:学学号:号:姓姓名:名:团队组成:团队组成:西北工业大学西北工业大学20222022 年年 4 4 月月 2727 日日请填写以下十项内容,将表格按页对齐(插入空行)请填写以下十项内容,将表格按页对齐(插入空行) ,勿删除任何部分。,勿删除任何部分。1 1、问题与背景(描述程序所要解决的问题或应用背景)、问题与背景(描述程序所要解决的问题或应用背景)一个简易的通讯录管理系统,可以实现对学生信息编辑,查询,保存以及打开的功能,可以用于管理学生的基本信息。2 2、开发工具(列出所使用的开发工具和第、开发工具(列出所使用的开

2、发工具和第 3 3 方开发库)方开发库)Code:block,DEV-C+3 3、主要功能(详细说明程序的功能)、主要功能(详细说明程序的功能)每个联系人信息包括该学生的姓名、学号、地址、联系电话、邮编、邮箱。(功能一)编辑通讯录1、增加联系人2、修改联系人3、删除联系人(功能二)查询联系人(1)按学生姓名查询(2)按学生学号查询(功能三)保存通信录(功能四)打开通讯录4 4、设计内容(详细描述解决问题的原理和方法、算法、数据结构等)、设计内容(详细描述解决问题的原理和方法、算法、数据结构等)程序的流程图如下图5 5、程序文件与工程名称(标出程序中所有文件名、工程名称及其说明)、程序文件与工程

3、名称(标出程序中所有文件名、工程名称及其说明)(1)main.cpp程序文件(2)学生通讯录管理系统.cbp工程文件6 6、函数模块(程序中各个函数的原型声明及其说明)、函数模块(程序中各个函数的原型声明及其说明)(1)void information:add(string name, string number,stringaddress,string telephone,string post,string mail)实现添加联系人的功能(2)void information:findname(string name)实现查找联系人的功能(3)void information:findnu

4、mber(string number)实现查找学号的功能(4)void information:correct(string name)实现对比输入的名字是否与通讯录的一致(5)void information:save()实现保存联系人的功能(6)void information:read()实现打来一个文件读取联系人的功能(7)int main()程序入口7 7、使用说明(运行程序的小型说明书)、使用说明(运行程序的小型说明书)(一)编辑通讯录1、增加联系人依次如果输入以下内容(以回车键切换) :输入姓名:张三输入地址:西工大长安校区输入邮编:710100输入邮箱:运行程序如下2、修改联系

5、人除 0 外,按任意键返回主菜单后选择此项功能。可输入准备修改联系人的名字后,再依次输入更新过后的姓名、学号、地址、联系电话、邮编、邮箱,运行程序如下。3、删除联系人返回主菜单后,选择此项功能后,输入要删除的姓名。如果输入的 1姓名不在通讯录里,则打印出“the student can.t be found in therecord” 。如下图若输入的姓名在通讯录中,就将其删除。(二)查询联系人(1)按学生姓名查询如果通讯录中没有记录的就打印出找不到的提示。(2)按学生学号查询(三)保存通信录可以将编辑好的通讯录保存成文件,例如保存为文本文档:张三.txt如果保存成功, 就打印出保存成功的提示

6、, 并且得到如下图所示的 txt文档。打开文件显示如下即保存成功。当然也可以保存成其他格式,只需将文件的后缀改变。这里不再赘述。(四)打开通讯录返回主菜单后,选择此项功能,输入要打开的记录名如:张三.txt。运行程序如下。当然也可以自己建立一个文件如:新通讯录.txt。 将其和学生通讯录管理系统可执行文件放在同一文件夹下。用程序也可以打开运行如下。8 8、程序开发总结(简要叙述编写本作业的收获与思考)、程序开发总结(简要叙述编写本作业的收获与思考)1、C+对 C 语言最重要的改进就是增加了类,功能十分强大,编的程序便于维护。通过本次作业,增加了我的编程能力,加深了对类的理解,对 C+有了更加深

7、入的了解。2.通过编程实践,我发现编写一个大一点的程序多么复杂,要掌握好c+就必须像老师说的那样多操作,不然水平就提不高。有很多东西你了解了,但当你去编写时,就会不断的暴露我们自己的问题,常常因为自己马虎或者对知识掌握不牢靠,不知道细节问题就常常出错。3.有时候当我们缺乏某个知识点时,可以查阅书籍,还可以上网搜索,甚至在自己的电脑上装 MSDN 可以随时获取帮助文档,同时提高英语水平。4,我认为这并不是一个完美的程序,为了完成课程设计,我只用了6天的时间使用 DEV-C+做了这个程序。因为它只假设用户按正常的逻辑去使用那些按钮的功能,这样虽然简单了, 但是没有在某些情况下禁用某些按钮,从而使得

8、某种功能的实现必须严谨考虑与其他按钮功能的关系,否则可能会给用户带来不便。要解决这个问题,最好是使用多个对话框来实现,使得其他的无关功能对用户不可见。9 9、运行截图(附上程序运行的截图画面,至少有、运行截图(附上程序运行的截图画面,至少有 1 1 幅,截图越翔实得分幅,截图越翔实得分越高)越高)增加联系人修改联系人删除联系人按学生姓名查询联系人按学生学号查询联系人保存通讯录打开通讯录1010、源程序(附上程序源代码,若是多个文件,标出文件名)、源程序(附上程序源代码,若是多个文件,标出文件名)#include#include#include#includeusing namespace st

9、d;static int n=0;struct student string name; string number; string address; string telephone; string post; string mail;class informationprivate: student st10;public: void add(string name, string number,string address,string telephone,string post,stringmail); void print(int i) couttt 姓名:sti.nameendl;

10、 couttt 学号:sti.numberendl; couttt 地址:sti.addressendl; couttt 电话:sti.telephoneendl; couttt 邮编:sti.postendl; couttt 邮箱:sti.mailendl; void findname(string name); void findnumber(string number); void correct(string name); void del(string); void save(); void read();void information:add(string name, strin

11、g number,string address,string telephone,stringpost,string mail) static int i=0; sti.address=address; sti.mail=mail; sti.name=name; sti.number=number; sti.post=post; sti.telephone=telephone; i+; n+;void information:findname(string name) int x=0; for(int i=0;i10;i+) if(sti.name=name) print(i); x=1; b

12、reak; if(x=0) coutthe man can.t be found in the record!endl;void information:findnumber(string number) int x=0; for(int i=0;i10;i+) if(sti.number=number) print(i); x=1; break; if(x=0) coutthe student can.t be found in the record!endl;void information:correct(string name) string number; string addres

13、s; string telephone; string post; string mail; int x=0; for(int i=0;i10;i+) if(sti.name=name) coutname; sti.name=name; coutnumber; sti.number=number; coutaddress; sti.address=address; couttelephone; sti.telephone=telephone; coutpost; sti.post=post; coutmail; sti.mail=mail; print(i); x=1; if(x=0) cou

14、tthe man can.t be found in the recordendl;void information:del(string name) int x=0; for(int i=0;i10;i+) if(sti.name=name) sti.address=0; sti.mail=0; sti.name=0; sti.number=0; sti.post=0; sti.telephone=0; x=1; print(i); if(x=0) coutthe student can.t be found in the recordendl;void information:save()

15、 string fileName;second:coutfileName; ofstream outFile(fileName.c_str(); if(!outFile) cerrterror:unable to open output file: fileNameendl; goto second; for(int i=0;in;i+) outFile 姓名:sti.namet; outFile 学号:sti.numbert; outFile 地址:sti.addresst; outFile 电话号码:sti.telephonet; outFile 邮编:sti.postt; outFile

16、 E_MAIL:sti.mailendl; outFile.close(); void information:read() vector svec; string fileName,s; cinfileName; ifstream inFile(fileName.c_str(); if(!inFile) cerrterror:unable to open output file: fileNameendl; while(getline(inFile,s) svec.push_back(s); for(vector:iterator iter=svec.begin();iter!=svec.e

17、nd();+iter) cout*iterendlendl;int main() information s;couttendl; coutendl; couttttwelcome to use the communication bookendl; coutttttttdesigned: 郭振超endl; couttt-endl;begin:couttt| 1.编辑通信录 2.查询联系人 |endl; couttt| 3.保存通信录 4.打开通记录 |endl; couttt-endl; string name; string number; string address; string t

18、elephone; string post; string mail; int val1; coutval1; switch(val1) case 1: couttt(1) 增加联系人endl; couttt(2) 修改联系人endl; couttt(3) 删除联系人endl; int val2; coutval2; switch(val2) case 1: coutname; coutnumber; coutaddress; couttelephone; coutpost; coutmail; s.add(name,number,address,telephone,post,mail); c

19、outback_add; if(back_add!=0) goto begin; else goto end; break; case 2: coutname; s.correct(name); coutback_correct; if(back_correct!=0) goto begin; else goto end; break; case 3: coutname; s.del(name); coutback_del; if(back_del!=0) goto begin; else goto end; break; break; case 2: couttt(1) 按学生姓名查询end

20、l; couttt(2) 按学生学号查询endl; int val3; coutval3; switch(val3) case 1: coutname; s.findname(name); coutback_findname; if(back_findname!=0) goto begin; else goto end; break; case 2: coutnumber; s.findnumber(number); coutback_findnumber; if(back_findnumber!=0) goto begin; else goto end; break; break; case

21、 3: coutval4; if(val4=n) cout放弃记录保存!endl; coutback_save; if(back_save!=0) goto begin; else goto end; else s.save(); coutt 保存成功!endl; coutback_save; if(back_save!=0) goto begin; else goto end; break; case 4: coutt 输入要打开的记录名:; s.read(); coutback_read; if(back_read!=0) goto begin; else goto end; break; end:coutt*成功退出系统,欢迎再次使用!*endl; return 0;

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

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