《通讯录管理系统的设计与实现c++源代码.docx》由会员分享,可在线阅读,更多相关《通讯录管理系统的设计与实现c++源代码.docx(6页珍藏版)》请在三一文库上搜索。
1、通讯录管理系统的设计与实现源代码#include#include#include#includeusingnamespacestd;structStudentstringnum;/学号stringname;/姓名intage;chartel;charaddr;charemal;Student*next;longiCount=0;Student*head=NULL;Student*pEnd=NULL;voidLoadRecords(char*path)/从文本里面读取记录fstreaminfile(path,ios:in);if(!infile)elseinfileiCount;intt=iCo
2、unt;if(iCount!=0)for(;iCount0;iCount-)Student*p=newStudent;infilep-nump-namep-Maths;if(head=NULL)head=p;pEnd=p;pEnd-next=NULL;elsepEnd-next=p;pEnd=pEnd-next;pEnd-next=NULL;iCount=t;infile.close();voidPrint(Student*h)/打印记录if(h=NULL)coutn*nn;cout没有学生记录!n;coutn*n;return;coutn*nn;cout所有的学生:nn;cout-n;cou
3、t|setw(10)学号|setw(10)姓名|setw(10)年龄|setw(10)电话|setw(10)地址|setw(10)邮箱|n;while(h)cout-n;cout|setw(10)num|setw(10)name|setw(10)age|setw(10)tel|setw(10)addr|setw(10)emalnext;cout-n;coutn*nn;voidPrint_All(Student*h)/输出全部if(h=NULL)coutn*n;cout没有学生记录!n;coutn*n;return;coutn*n;cout所有学生:nn;cout-n;cout|setw(10)
4、学号|setw(10)姓名|setw(10)年龄|setw(10)电话|setw(10)地址|setw(10)邮箱number=1;h-number+cout-n;cout|setw(10)num|setw(10)name|setw(10)age|setw(10)tel|setw(10)addr|setw(10)emalnext;cout-n;coutn*nn;voidPrint_search(Student*h)/查询if(h=NULL)coutn*n;cout没有学生记录!n;coutn*n;return;coutn*n;cout所查学生:nn;cout-n;cout|setw(10)学号
5、|setw(10)姓名|setw(10)年龄|setw(10)电话|setw(10)地址|setw(10)邮箱number=i)cout-n;cout|setw(10)num|setw(10)name|setw(10)age|setw(10)tel|setw(10)addr|setw(10)emalnext;cout-n;coutnext=NULL;elsepEnd-next=s;pEnd=s;pEnd-next=NULL;coutn=n;coutname的资料添加完毕!n;cout=n;iCount+;voidmain()LoadRecords(c:test.txt);intn;coutn*
6、n;cout1增加一个学生n2显示所有的学生以及他们的成绩n3显示数组中学号为I的学生信息n4存盘并退出n;cout*nn;coutn;while(1)switch(n)case1:Student*p=newStudent;coutn*nn;cout请输入内容:endl;coutp-nump-namep-agep-telp-addrp-emal;Add(p);break;case2:Print(head);break;case3:Print_search(head);break;case4:fstreamoutfile(c:test.txt,ios:out);if(!outfile)elseoutfileiCount;while(head)outfilenumnameMathsnext;outfile.close();coutn=n;cout再见endl;cout=nn;return;default:coutn=n;cout无效输入endl;cout=nn;cout=1&n=5)coutn*n;cout1增加一个学生n2显示所有的学生以及他们的成绩n3显示数组中平均成绩40的学生以及他们的成绩n4显示数组中学号为I的学生信息n5存盘并退出n;cout*nn;coutn;