班级通讯录Word格式.docx
- 文档编号:17415007
- 上传时间:2022-12-01
- 格式:DOCX
- 页数:11
- 大小:16.02KB
班级通讯录Word格式.docx
《班级通讯录Word格式.docx》由会员分享,可在线阅读,更多相关《班级通讯录Word格式.docx(11页珍藏版)》请在冰豆网上搜索。
postcode=newchar[7];
address=newchar[30];
voidinput();
//声明input函数char*getname()//输入姓名
returnname;
char*getbanji()//输入班级
returnbanji;
char*getphone()//输入手机号码{
returnphone;
char*gettel()//输入家庭电话
returntel;
char*getmail()//输入电子邮件地址{
returnmail;
char*getpostcode()//输入邮编
returnpostcode;
char*getaddress()//输入住址
returnaddress;
voidoutput();
//输出
student(student&
stud);
//声明copy构造函数
~student();
//声明析构函数
private:
char*name;
char*banji;
char*phone;
char*tel;
char*postcode;
char*mail;
char*address;
};
voidstudent:
:
input()
"
请输入联系人姓名:
;
strsave(name);
//调用函数strsave()
请输入联系人班级:
strsave(banji);
请输入联系人手机号码:
strsave(phone);
请输入联系人家庭电话号码:
strsave(tel);
请输入联系人电子邮箱地址:
strsave(mail);
请输入联系人邮编:
strsave(postcode);
请输入联系人住址:
strsave(address);
output()
姓名:
name<
班级:
banji<
手机号码:
phone<
家庭电话:
"
tel<
endl<
电子邮箱:
mail<
邮编:
postcode<
住址:
address<
student:
stud)//定义copy构造函数{
name=newchar(strlen(stud.name)+1);
banji=newchar(strlen(stud.banji)+1);
phone=newchar(strlen(stud.phone)+1);
tel=newchar(strlen(stud.tel)+1);
mail=newchar(strlen(stud.mail)+1);
postcode=newchar(strlen(stud.postcode)+1);
address=newchar(strlen(stud.address)+1);
if(name!
=0)
strcpy(name,stud.name);
strcpy(banji,stud.banji);
strcpy(phone,stud.phone);
strcpy(tel,stud.tel);
strcpy(mail,stud.mail);
strcpy(postcode,stud.postcode);
strcpy(address,stud.address);
~student()//定义析构函数
deletename;
deletebanji;
deletephone;
deletetel;
deletemail;
deletepostcode;
deleteaddress;
classhanshu//定义hanshu类
intstudentnam;
ints;
intk;
student*stud;
hanshu()
stud=newstudent[100];
studentnam=0;
k=0;
s=0;
voidoutput(inti);
intchazhao(char*nam);
voidxiugai(intn);
voidzenjia();
intgetstudentnam();
voidshanchu(intn);
voidout();
voidhanshu:
out()//输出联系人信息,保存为
for(inti=0;
i<
studentnam;
i++)
stud[i].output();
ofstreamfout("
班级通讯录.txt"
ios:
out);
if(!
fout)
保存失败"
fout<
姓名"
stud[i].getname()<
班级"
stud[i].getbanji()<
手机号码"
stud[i].getphone()<
家庭电话"
stud[i].gettel()<
电子邮箱"
stud[i].getmail()<
邮编"
stud[i].getpostcode()<
地址"
stud[i].getaddress()<
fout.close();
output(inti)
inthanshu:
getstudentnam()
returnstudentnam;
chazhao(char*nam)//查找联系人
inti,flag=0;
for(i=0;
strcmp(stud[i].getname(),nam))
flag=1;
break;
if(flag==1)
return(i+1);
else
return0;
xiugai(intn)//修改联系人
您要修改为:
stud[n].input();
zenjia()//增加联系人
if(studentnam<
100)
stud[studentnam].input();
studentnam++;
shanchu(intn)//删除联系人
inti;
for(i=n;
(i+1)<
stud[i]=stud[i+1];
studentnam--;
intmain()
chark,m,t;
intn,j;
hanshua;
//hanshu类对象a
studentstud;
//student类对象stud
>
欢迎使用班级通讯录<
do{
|----------------------------------------------|"
|1新建联系人|"
|2删除联系人|"
|3修改联系人|"
|4查找联系人|"
|5输出|"
cout<
请选择服务选项>
cin>
k;
switch(k)//菜单选项
case'
1'
n=(100-a.getstudentnam());
do{
if(a.getstudentnam()<
(只能增加"
n<
个联系人)"
a.zenjia();
n--;
\t\t增加成功"
\t\t是否继续增加(y/n)"
\t\t\t"
m;
空间不足,无法增加!
}while(m=='
y'
||m=='
Y'
);
2'
n=a.getstudentnam();
charnam[20];
你能删除"
个联系人"
请输入您需要删除的联系人姓名:
nam;
j=a.chazhao(nam);
if(n!
=0&
&
j!
a.shanchu(j-1);
\t\t删除成功"
if(n==0&
不能删除,目前通录中联系人个数为0"
if(j==0&
n!
没有您要删除的联系人"
\t\t是否继续删除(y/n)"
3'
do
请输入您需要修改的联系人姓名:
n=a.chazhao(nam);
a.xiugai(n-1);
没有您要修改的联系人"
是否继续修改(y/n)"
t;
}while(t=='
||t=='
4'
请输入您需要查找的联系人姓名:
a.output(n-1);
没有您要查找的联系人"
是否继续查找(y/n)"
5'
a.out();
\n\n是否继续系统服务(y/n)"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 班级 通讯录
![提示](https://static.bdocx.com/images/bang_tan.gif)