C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx

上传人:b****6 文档编号:21728578 上传时间:2023-02-01 格式:DOCX 页数:32 大小:412.91KB
下载 相关 举报
C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx_第1页
第1页 / 共32页
C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx_第2页
第2页 / 共32页
C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx_第3页
第3页 / 共32页
C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx_第4页
第4页 / 共32页
C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx_第5页
第5页 / 共32页
点击查看更多>>
下载资源
资源描述

C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx

《C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx(32页珍藏版)》请在冰豆网上搜索。

C++面向对象程序设计通讯录课程设计报告8Word格式文档下载.docx

//xx

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<

<

"

返回还是回到主菜单(T为退出,R为回到主菜单,不计大小写):

"

;

charback;

cin>

>

back;

if(back=='

R'

||back=='

r'

return1;

else

return0;

}

voidprint(inti)

{

学号:

st[i].no<

endl;

姓名:

st[i].name<

地址:

st[i].address<

xx号码:

st[i].tel_no<

邮编:

st[i].post_code<

E_MAIL:

st[i].e_mail<

//主函数首页

intmain()

intera;

a.format();

charselect1;

cout<

top:

cout<

\t\t计科N082"

<

endl

<

\t\t★★★★★★★★★★★★★★★★★★★★★★★★★★"

\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;

输入xx号码:

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=='

||back_add=='

gototop;

else

gotobottom;

break;

2'

输入要删除人的姓名:

charname2[20];

name2;

a.del(name2);

charback_del;

back_del;

if(back_del=='

||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=='

||back_f1=='

charno4[13];

no4;

a.find1(no4);

charback_f2;

back_f2;

if(back_f2=='

||back_f2=='

a.write();

charback_w;

back_w;

if(back_w=='

||back_w=='

gototop;

gotobottom;

4'

(1)按学号排序:

(2)按姓名排序:

charselect4;

select4;

switch(select4)

a.list1();

charback;

if(back=='

a.list2();

charback1;

back1;

if(back1=='

||back1=='

5'

a.read();

charback_r;

back_r;

if(back_r=='

||back_r=='

6'

请确认删除所有资料!

(Y/N)"

charselect5;

select5;

if(select5=='

Y'

||select5=='

y'

a.format();

charback_f;

back_f;

if(back_f=='

||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,"

elsex=0;

if(x==0)

error:

输入姓名错误!

//修改联系人

intinter:

correct(charname[30])

intx;

x=i;

charselect;

(1)修改姓名:

(2)修改学号:

(3)修改地址:

(4)修改邮编:

(5)修改xx号码:

(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);

输入要修改的xx号码:

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])

输入的姓名查找不到!

//读取文件

read()

{

charname1[20];

输入你要导入的文件名:

strcat(name1,"

.txt"

ifstreamfile(name1);

charline[120];

charno[120];

charname[120];

charaddress[120];

charpost_code[120];

chartel_no[120];

chare_mail[120];

inttime=0;

file.getline(line,120);

while(!

file.eof())

for(intk=0;

k<

k++)

if(time==0)

{

strcpy(no,line);

time=1;

for(inti=0;

120;

if(no[i]=='

'

{

i++;

for(intj=0;

j<

13;

j++)

{

st[k].no[j]=no[i];

i++;

}

}

}

file.getline(line,120,'

\n'

if(time==1)

strcpy(name,line);

time=2;

if(name[i]=='

20;

st[k].name[j]=name[i];

if(time==2)

strcpy(address,line);

time=3;

if(address[i]=='

100;

st[k].address[j]=address[i];

}

if(time==3)

strcpy(tel_no,line);

time=4;

if(tel_no[i]=='

for(int

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 合同协议

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1