通讯录程序设计Word格式文档下载.docx
《通讯录程序设计Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《通讯录程序设计Word格式文档下载.docx(37页珍藏版)》请在冰点文库上搜索。
a.list1()函数用于通讯录中的信息进行排序,主要流程如下:
a.read()函数用于从文本文件中读取信息,主要流程如下:
a.write()函数用于将信息写入文本文件,主要流程如下:
三、主要数据结构
结构数组:
structstudent//结构体
{
charno[13];
//学号
charname[20];
//姓名
charaddress[100];
//地址
chartel_no[12];
//电话
charpost_code[7];
//邮编
chare_mail[40];
//E-mail
}
classinter//派生类
private:
//派生类增加或替代的私有成员
studentst[35];
public:
//派生类增加或替代的公有成员
voidadd(charno[13],charname[20],charaddress[100],chartel_no[12],charpost_code[7],chare_mail[40]);
//成员函数,添加联系人
voiddel(charname[20]);
//成员函数,删除联系人
voidfind1(charno[13]);
//成员函数,按学号查找联系人
voidfind2(charname[20]);
//成员函数,按姓名查找联系人
voidlist1();
//成员函数,排序联系人
voidlist2();
intcorrect(charname[20]);
//成员函数,修改联系人
voidread();
//成员函数,读取文本文件
voidwrite();
//成员函数,写入文本文件
voidformat();
//成员函数,格式化内存保存的数据
intback()
//成员函数,返回首页
voidprint(inti)
//成员函数,输出显示
}
四、流程图
五、源代码
#include<
iostream.h>
fstream.h>
string.h>
charno[13];
charname[20];
charaddress[100];
chartel_no[12];
charpost_code[7];
chare_mail[40];
};
classinter
intback()
{
cout<
<
"
按0键退出系统,按其他键返回主菜单:
;
charback;
cin>
>
back;
if(back!
='
0'
)
return1;
else
return0;
}
voidprint(inti)
{
学号:
st[i].no<
endl;
姓名:
st[i].name<
地址:
st[i].address<
电话号码:
st[i].tel_no<
邮编:
st[i].post_code<
E_MAIL:
st[i].e_mail<
//主函数首页
intmain()
intera;
a.format();
charselect1;
cout<
top:
cout<
\t\t##################################################"
<
endl
<
\t\t##"
\t\t#通迅录#"
endl
\t\t#1.通讯录编辑4.联系人排序#"
\t\t#2.查询联系人5.打开通讯录#"
\t\t#3.保存通讯录6.格式化数据#"
\t\t"
endl<
\t\t\t输入你要使用的功能序号:
;
cin>
select1;
switch(select1)
case'
1'
:
(1)添加联系人:
(2)删除联系人:
(3)修改联系人:
charselect2;
请选择:
select2;
switch(select2)
{
case'
输入要添加的联系人资料:
charno[13];
cout<
输入学号:
cin>
no;
输入姓名:
name;
输入地址:
address;
输入电话号码:
tel_no;
输入邮编:
post_code;
输入E_mail:
e_mail;
a.add(no,name,address,tel_no,post_code,e_mail);
charback_add;
back_add;
if(back_add!
gototop;
else
gotobottom;
break;
2'
输入要删除的联系人姓名:
charname2[20];
name2;
a.del(name2);
charback_del;
back_del;
if(back_del!
3'
输入需要修改的联系人姓名:
charname3[20];
name3;
if(a.correct(name3))
elsegotobottom;
}
break;
(1)根据姓名查找"
(2)根据学号查找"
charselect3;
"
select3;
switch(select3)
charname4[20];
name4;
a.find2(name4);
charback_f1;
back_f1;
if(back_f1!
charno4[13];
no4;
a.find1(no4);
charback_f2;
back_f2;
if(back_f2!
a.write();
charback_w;
back_w;
if(back_w!
gototop;
gotobottom;
4'
(1)按学号排序:
(2)按姓名排序:
charselect4;
select4;
switch(select4)
a.list1();
charback;
if(back!
a.list2();
charback1;
back1;
if(back1!
5'
a.read();
charback_r;
back_r;
if(back_r!
6'
请确认删除所有资料!
(Y/N)"
charselect5;
select5;
if(select5=='
Y'
||select5=='
y'
a.format();
charback_f;
back_f;
if(back_f!
bottom:
********成功退出系统,欢迎再次使用!
********"
return0;
//添加联系人
voidinter:
add(charno[13],charname[20],charaddress[100],chartel_no[12],charpost_code[7],chare_mail[40])
intx=1;
for(inti=0;
i<
35;
i++)
if(!
strcmp(st[i].no,"
0"
))
strcpy(st[i].address,address);
strcpy(st[i].e_mail,e_mail);
strcpy(st[i].name,name);
strcpy(st[i].no,no);
strcpy(st[i].post_code,post_code);
strcpy(st[i].tel_no,tel_no);
x=0;
if(x==0)
//删除联系人
del(charname[20])
{intx=1;
strcmp(st[i].name,name))
strcpy(st[i].address,"
);
strcpy(st[i].e_mail,"
strcpy(st[i].name,"
strcpy(st[i].no,"
strcpy(st[i].post_code,"
strcpy(st[i].tel_no,"
x=0;
”删除此联系人成功!
”<
if(x==1)
输入有误,没有找到此联系人!
//修改联系人
intinter:
correct(charname[30])
intx;
x=i;
charselect;
(1)修改姓名:
(2)修改学号:
(3)修改地址:
(4)修改邮编:
(5)修改电话号码:
(6)修改E_MAIL:
select;
switch(select)
输入姓名进行修改:
charname1[30];
name1;
strcpy(st[x].name,name1);
修改成功!
returnback();
输入学号进行修改:
charno1[13];
no1;
strcpy(st[i].no,no1);
输入地址进行修改:
charaddress1[100];
address1;
strcpy(st[x].address,address1);
输入邮编进行修改:
charpost_code1[7];
post_code1;
strcpy(st[x].post_code,post_code1);
输入电话号码进行修改:
chartel_no1[12];
tel_no1;
strcpy(st[x].tel_no,tel_no1);
输入E_MAIL进行修改:
chare_mail1[40];
e_mail1;
strcpy(st[x].e_mail,e_mail1);
//按学号查询联系人
find1(charno[13])
intx,y=1,z=1;
strcmp(st[i].no,no))
z=0;
elsey=0;
if(z==0)
}
if(y==0)
没有查到此学号的相关记录!
print(x);
//按姓名查询联系人
find2(charname[20])