西北工业大学C大作业第题.docx
- 文档编号:8064246
- 上传时间:2023-01-28
- 格式:DOCX
- 页数:15
- 大小:18.76KB
西北工业大学C大作业第题.docx
《西北工业大学C大作业第题.docx》由会员分享,可在线阅读,更多相关《西北工业大学C大作业第题.docx(15页珍藏版)》请在冰豆网上搜索。
西北工业大学C大作业第题
作业名称:
学生通讯录管理系统
学院:
自动化学院
班级:
学号:
姓名:
团队组成:
西北工业大学
2022年4月27日
请填写以下十项内容,将表格按页对齐(插入空行),勿删除任何部分。
1、问题与背景(描述程序所要解决的问题或应用背景)
一个简易的通讯录管理系统,可以实现对学生信息编辑,查询,保存以及打开的功能,可以用于管理学生的基本信息。
2、开发工具(列出所使用的开发工具和第3方开发库)
Code:
:
block,DEV-C++
3、主要功能(详细说明程序的功能)
每个联系人信息包括该学生的姓名、学号、地址、联系电话、邮编、邮箱。
(功能一)编辑通讯录
1、增加联系人
2、修改联系人
3、删除联系人
(功能二)查询联系人
(1)按学生姓名查询
(2)按学生学号查询
(功能三)保存通信录
(功能四)打开通讯录
4、设计内容(详细描述解决问题的原理和方法、算法、数据结构等)
程序的流程图如下图
5、程序文件与工程名称(标出程序中所有文件名、工程名称及其说明)
(1)main.cpp程序文件
(2)学生通讯录管理系统.cbp工程文件
6、函数模块(程序中各个函数的原型声明及其说明)
(1)voidinformation:
:
add(stringname,stringnumber,stringaddress,stringtelephone,stringpost,stringmail)
实现添加联系人的功能
(2)voidinformation:
:
findname(stringname)
实现查找联系人的功能
(3)voidinformation:
:
findnumber(stringnumber)
实现查找学号的功能
(4)voidinformation:
:
correct(stringname)
实现对比输入的名字是否与通讯录的一致
(5)voidinformation:
:
save()
实现保存联系人的功能
(6)voidinformation:
:
read()
实现打来一个文件读取联系人的功能
(7)intmain()
程序入口
7、使用说明(运行程序的小型说明书)
(一)编辑通讯录
1、增加联系人
依次如果输入以下内容(以回车键切换):
输入姓名:
张三
输入地址:
西工大长安校区
输入邮编:
710100
输入邮箱:
运行程序如下
2、修改联系人
除0外,按任意键返回主菜单后选择此项功能。
可输入准备修改联系人的名字后,再依次输入更新过后的姓名、学号、地址、联系电话、邮编、邮箱,运行程序如下。
3、删除联系人
返回主菜单后,选择此项功能后,输入要删除的姓名。
如果输入的1姓名不在通讯录里,则打印出“thestudentcan.tbefoundintherecord”。
如下图
若输入的姓名在通讯录中,就将其删除。
(二)查询联系人
(1)按学生姓名查询
如果通讯录中没有记录的就打印出找不到的提示。
(2)按学生学号查询
(三)保存通信录
可以将编辑好的通讯录保存成文件,例如保存为文本文档:
张三.txt
如果保存成功,就打印出保存成功的提示,并且得到如下图所示的txt文档。
打开文件显示如下
即保存成功。
当然也可以保存成其他格式,只需将文件的后缀改变。
这里不再赘述。
(四)打开通讯录
返回主菜单后,选择此项功能,输入要打开的记录名如:
张三.txt。
运行程序如下。
当然也可以自己建立一个文件如:
新通讯录.txt。
将其和学生通讯录管理系统可执行文件放在同一文件夹下。
用程序也可以打开运行如下。
8、程序开发总结(简要叙述编写本作业的收获与思考)
1、C++对C语言最重要的改进就是增加了类,功能十分强大,编的程序便于维护。
通过本次作业,增加了我的编程能力,加深了对类的理解,对C++有了更加深入的了解。
2.通过编程实践,我发现编写一个大一点的程序多么复杂,要掌握好c++就必须像老师说的那样多操作,不然水平就提不高。
有很多东西你了解了,但当你去编写时,就会不断的暴露我们自己的问题,常常因为自己马虎或者对知识掌握不牢靠,不知道细节问题就常常出错。
3.有时候当我们缺乏某个知识点时,可以查阅书籍,还可以上网搜索,甚至在自己的电脑上装MSDN可以随时获取帮助文档,同时提高英语水平。
4,我认为这并不是一个完美的程序,为了完成课程设计,我只用了6天的时间使用DEV-C++做了这个程序。
因为它只假设用户按正常的逻辑去使用那些按钮的功能,这样虽然简单了,但是没有在某些情况下禁用某些按钮,从而使得某种功能的实现必须严谨考虑与其他按钮功能的关系,否则可能会给用户带来不便。
要解决这个问题,最好是使用多个对话框来实现,使得其他的无关功能对用户不可见。
9、运行截图(附上程序运行的截图画面,至少有1幅,截图越翔实得分越高)
增加联系人
修改联系人
删除联系人
按学生姓名查询联系人
按学生学号查询联系人
保存通讯录
打开通讯录
10、源程序(附上程序源代码,若是多个文件,标出文件名)
#include
#include
#include
#include
usingnamespacestd;
staticintn=0;
structstudent{
stringname;
stringnumber;
stringaddress;
stringtelephone;
stringpost;
stringmail;
};
classinformation{
private:
studentst[10];
public:
voidadd(stringname,stringnumber,stringaddress,stringtelephone,stringpost,stringmail);
voidprint(inti)
{
cout<<"\t\t姓名:
"< cout<<"\t\t学号: "< cout<<"\t\t地址: "< cout<<"\t\t电话: "< cout<<"\t\t邮编: "< cout<<"\t\t邮箱: "< } voidfindname(stringname); voidfindnumber(stringnumber); voidcorrect(stringname); voiddel(string); voidsave(); voidread(); }; voidinformation: : add(stringname,stringnumber,stringaddress,stringtelephone,stringpost,stringmail) { staticinti=0; st[i].address=address; st[i].mail=mail; st[i].name=name; st[i].number=number; st[i].post=post; st[i].telephone=telephone; i++; n++; } voidinformation: : findname(stringname) { intx=0; for(inti=0;i<10;i++) { if(st[i].name==name) { print(i); x=1; break; } } if(x==0) cout<<"themancan.tbefoundintherecord! "< } voidinformation: : findnumber(stringnumber) { intx=0; for(inti=0;i<10;i++) { if(st[i].number==number) { print(i); x=1; break; } } if(x==0) cout<<"thestudentcan.tbefoundintherecord! "< } voidinformation: : correct(stringname) { stringnumber; stringaddress; stringtelephone; stringpost; stringmail; intx=0; for(inti=0;i<10;i++) { if(st[i].name==name) { cout<<"\t输入要修改的姓名: "; cin>>name; st[i].name=name; cout<<"\t输入要修改的学号: "; cin>>number; st[i].number=number; cout<<"\t输入要修改的地址: "; cin>>address; st[i].address=address; cout<<"\t输入要修改的电话: "; cin>>telephone; st[i].telephone=telephone; cout<<"\t输入要修改的邮编: "; cin>>post; st[i].post=post; cout<<"\t输入要修改的邮箱: "; cin>>mail; st[i].mail=mail; print(i); x=1; } } if(x==0) cout<<"themancan.tbefoundintherecord"< } voidinformation: : del(stringname) { intx=0; for(inti=0;i<10;i++) { if(st[i].name==name) { st[i].address="0"; st[i].mail="0"; st[i].name="0"; st[i].number="0"; st[i].post="0"; st[i].telephone="0"; x=1; print(i); } } if(x==0) cout<<"thestudentcan.tbefoundintherecord"< } voidinformation: : save() { stringfileName; second: cout<<"\t输入要保存的文件名: "; cin>>fileName; ofstreamoutFile(fileName.c_str()); if(! outFile){ cerr<<"\terror: unabletoopenoutputfile: "< gotosecond; } for(inti=0;i { outFile<<"姓名: "< outFile<<"学号: "< outFile<<"地址: "< outFile<<"电话号码: "< outFile<<"邮编: "< outFile<<"E_MAIL: "< } outFile.close(); } voidinformation: : read() { vector stringfileName,s; cin>>fileName; ifstreaminFile(fileName.c_str()); if(! inFile){ cerr<<"\terror: unabletoopenoutputfile: "< } while(getline(inFile,s)) svec.push_back(s); for(vector : iteratoriter=svec.begin();iter! =svec.end();++iter) cout<<*iter< } intmain() { informations; cout<<"\t★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★"< cout< cout<<"\t\t\twelcometousethecommunicationbook"< cout<<"\t\t\t\t\t\tdesigned: 郭振超"< cout<<"\t\t----------------------------------------------------"< begin: cout<<"\t\t|1.编辑通信录2.查询联系人|"< cout<<"\t\t|3.保存通信录4.打开通记录|"< cout<<"\t\t----------------------------------------------------"< stringname; stringnumber; stringaddress; stringtelephone; stringpost; stringmail; intval1; cout<<"\t\t请选择功能号: "; cin>>val1; switch(val1) { case1: cout<<"\t\t (1)增加联系人"< cout<<"\t\t (2)修改联系人"< cout<<"\t\t(3)删除联系人"< intval2; cout<<"\t\t请选择选项: "; cin>>val2; switch(val2) { case1: cout<<"\t输入姓名: "; cin>>name; cout<<"\t输入学号: "; cin>>number; cout<<"\t输入地址: "; cin>>address; cout<<"\t输入电话: "; cin>>telephone; cout<<"\t输入邮编: "; cin>>post; cout<<"\t输入邮箱: "; cin>>mail; s.add(name,number,address,telephone,post,mail); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_add; cin>>back_add; if(back_add! =0) gotobegin; else gotoend; break; case2: cout<<"\t请输入要修改的学生姓名: "; cin>>name; s.correct(name); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_correct; cin>>back_correct; if(back_correct! =0) gotobegin; else gotoend; break; case3: cout<<"\t请输入要删除的学生信息的学生姓名: "; cin>>name; s.del(name); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_del; cin>>back_del; if(back_del! =0) gotobegin; else gotoend; break; } break; case2: cout<<"\t\t (1)按学生姓名查询"< cout<<"\t\t (2)按学生学号查询"< intval3; cout<<"\t\t请选择选项: "; cin>>val3; switch(val3) { case1: cout<<"\t请输入查询的学生姓名: "; cin>>name; s.findname(name); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_findname; cin>>back_findname; if(back_findname! =0) gotobegin; else gotoend; break; case2: cout<<"\t请输入查询的学生学号: "; cin>>number; s.findnumber(number); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_findnumber; cin>>back_findnumber; if(back_findnumber! =0) gotobegin; else gotoend; break; } break; case3: cout<<"\t确定保存修改的记录吗(请输入y或n进行选择): "; charval4; cin>>val4; if(val4=='n') { cout<<"放弃记录保存! "< cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_save; cin>>back_save; if(back_save! =0) gotobegin; else gotoend; } else { s.save(); cout<<"\t保存成功! "< cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_save; cin>>back_save; if(back_save! =0) gotobegin; else gotoend; } break; case4: cout<<"\t输入要打开的记录名: "; s.read(); cout<<"\t\t按0键退出系统,按其他键返回主菜单: "; intback_read; cin>>back_read; if(back_read! =0) gotobegin; else gotoend; break; } end: cout<<"\t**********成功退出系统,欢迎再次使用! **********"< return0; }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 西北工业大学 作业