完整word版通讯录管理系统源代码.docx
- 文档编号:3562146
- 上传时间:2023-05-06
- 格式:DOCX
- 页数:22
- 大小:16.84KB
完整word版通讯录管理系统源代码.docx
《完整word版通讯录管理系统源代码.docx》由会员分享,可在线阅读,更多相关《完整word版通讯录管理系统源代码.docx(22页珍藏版)》请在冰点文库上搜索。
完整word版通讯录管理系统源代码
源代码:
#includestdio.h
#includestdlib.h
#includestring.h
#includeconio.h
#includestdlib.h
#definenull0
structrecord
{
charname[20];
charphone[20];
charadress[40];
charpostcode[10];
chare_mail[30];
}student[500];
structLinkList
{
structrecordUS;
structLinkList*next;
}a;
structLinkList*head=null;
intnum=0;
FILE*fp;
intmenu_select();
intadduser();
intlist();
intsearch();
intdisplay();
intadd();
intlistbyname();
intdele();
intsave();
intexit();
voidmain()
{
system(cls);
for(;;)
{
switch(menu_select())
{
case0:
adduser();break;
case1:
list();break;
case2:
search();break;
case3:
display();break;
case4:
add();break;
case5:
listbyname();break;
case6:
dele();break;
case7:
save();break;
case8:
exit(0);
}
}
}
menu_select()
{
chars[80];
inta;
printf(*_*pressanykeyentermenu!
*_*\n);
getch();
system(cls);
printf(\\t********************MENU*********************\n\n);
printf(\\t0.输入记录\n);
printf(\\t1.显示记录\n);
printf(\\t2.按姓名查找\n);
printf(\\t3.按电话号码查找\n);
printf(\\t4.插入记录\n);
printf(\\t5.按姓名排序\n);
printf(\\t6.删除记录\n);
printf(\\t7.记录保存文件\n);
printf(\\t8.Quit\n);
printf(\\t***********************************************\n);
do{
printf(\
Enteryouchoice(0~11):
);
scanf(%s,s);
a=atoi(s);
}
while(a<0||a>11);
returna;
}
adduser()
{
printf(\
\t\t****************请输入用户信息****************\n);
printf(\
\t\t输入姓名:
);
scanf(%s,&student[num].name);
printf(\
\t\t输入电话号码:
);
scanf(%s,&student[num].phone);
printf(\
\t\t输入地址:
);
scanf(%s,&student[num].adress);
printf(\
\t\t输入邮编:
);
scanf(%s,&student[num].postcode);
printf(\
\t\t输入e-mail:
);
scanf(%s,&student[num].e_mail);
num++;
printf(\
\t\t是否继续添加?
(Y/N):
);
if(getch()=='y')
adduser();
return(0);
}
list()
{
inti;
system(cls);
if(num!
=0)
{
printf(\
\t\t***************以下为通讯录所有信息************);
for(i=0;i { printf(\ \t\t姓名: %s,student[i].name); printf(\ \t\t电话: %s,student[i].phone); printf(\ \t\t地址: %s,student[i].adress); printf(\ \t\t邮编: %s,student[i].postcode); printf(\ \t\te-mail: %s,student[i].e_mail); printf(\\t); if(i+1 { printf(\ \t\t__________________________); system(pause); } } printf(\ \t\t************************************************); } else printf(\ \t\t通讯录中无任何纪录); printf(\ \t\t按任意键返回主菜单: ); getch(); return(0); } search() { intmark=0; inti; inta=0; printf(\ \t\t*****************按姓名查找*******************); charname[20]; printf(\ \t\t请输入姓名: ); scanf(%s,name); for(i=a;i { if(strcmp(student[i].name,name)==0) { printf(\ \t\t*************以下是您查找的用户信息***********); printf(\ \t\t姓名: %s,student[i].name); printf(\ \t\t电话: %s,student[i].phone); printf(\ \t\t地址: %s,student[i].adress); printf(\ \t\te-mail: %s,student[i].e_mail); printf(\ \t\t************************************************); mark++; if((i+1) { printf(\ \t\t是否继续查找相同名字的用户信息: (y/n)); if(getch()=='y') { a=i; continue; } else return(0); } else { printf(\ \t\t按任意键返回主菜单); getch(); return(0); } } } if(mark! =0) { printf(\ \t\t没有相同姓名的用户纪录); printf(\ \t\t按任意键返回主菜单); getch(); return(0); } else { printf(\ \t\t没有相同姓名的用户纪录); printf(\ \t\t按任意键返回主菜单); getch(); return(0); } } display() { intmark=0; inti; inta=0; printf(\ \t\t******************按电话查找******************); charphone[10]; printf(\ \t\t请输入电话号码: ); scanf(%s,phone); for(i=0;i { if(strcmp(student[i].phone,phone)==0) { printf(\ \t\t**************以下是您查找的用户信息**********); printf(\ \t\t姓名: %s,student[i].name); printf(\ \t\t电话: %s,student[i].phone); printf(\ \t\t地址: %s,student[i].adress); printf(\ \t\te-mail: %s,student[i].e_mail); printf(\ \t\t************************************************); printf(\ \t\t按任意键返回主菜单: ); mark++; getch(); return(0); } } if(mark==0) { printf(\ \t\t没有改用户的信息); printf(\ \t\t按任意键返回主菜单); getch(); return(0); } return(0); } add() { inti; if((fp=fopen(student.bin,wb))==NULL) { printf(\ \t\t文件打开失败); } for(i=0;i { if(fwrite(&student[i],sizeof(structrecord),1,fp)! =1) { printf(\ \t\t写入文件错误! \n); } printf(\ \t\t****************请输入用户信息****************\n); printf(\ \t\t输入姓名: ); scanf(%s,&student[num].name); printf(\ \t\t输入电话号码: ); scanf(%s,&student[num].phone); printf(\ \t\t输入地址: ); scanf(%s,&student[num].adress); printf(\ \t\t输入邮编: ); scanf(%s,&student[num].postcode); printf(\ \t\t输入e-mail: ); scanf(%s,&student[num].e_mail); num++; printf(\ \t\t是否继续添加? (Y/N): ); if(getch()=='y') adduser(); return(0); } fclose(fp); printf(\ \t\t通讯录文件已保存); \n\t\t);按任意键退出程序printf(\ \t\t exit(0); return(0); } voiddeletebyphone() { inti,j; intdeletemark=0; charphone[20]; printf(\ \t\t请输入要删除用户电话号码: ); scanf(%s,phone); if(num==0) { printf(\ \t\t对不起,文件中无任何纪录); printf(\ \t\t按任意键返回主菜单); getch(); return; } for(i=0;i { if(strcmp(student[i].phone,phone)==NULL) { printf(\ \t\t以下是您要删除的用户纪录: ); printf(\ \t\t姓名: %s,student[i].name); printf(\ \t\t电话: %s,student[i].phone); printf(\ \t\t地址: %s,student[i].adress); printf(\ \t\te-mail: %s,student[i].e_mail); printf(\ \t\t是否删除? (y/n)); if(getch()=='y') { for(j=i;j student[j]=student[j+1]; num--; deletemark++; printf(\ \t\t删除成功); printf(\ \t\t是否继续删除? (y/n)); if(getch()=='y') deletebyphone(); return; } else return; } continue; } if(deletemark==0) { printf(\ \t\t没有该用户的纪录); printf(\ \t\t是否继续删除? (y/n)); if(getch()=='y') deletebyphone(); return; } } voiddeletebyname() { inta=0; intfindmark=0; intj; intdeletemark=0; inti; charname[20]; printf(\ \t\t请输入要删除用户姓名: ); scanf(%s,name); for(i=a;i { if(strcmp(student[i].name,name)==NULL) { printf(\ \t\t以下是您要删除的用户纪录: ); findmark++; printf(\ \t\t________________________________); printf(\ \t\t姓名: %s,student[i].name); printf(\ \t\t电话: %s,student[i].phone); printf(\ \t\t地址: %s,student[i].adress); printf(\ \t\te-mail: %s,student[i].e_mail); printf(\ \t\t________________________________); printf(\ \t\t是否删除? (y/n)); if(getch()=='y') { for(j=i;j student[j]=student[j+1]; num--; deletemark++; printf(\ \t\t删除成功); if((i+1) { printf(\ \t\t是否继续删除相同姓名的用户信息? (y/n)); if(getch()=='y') { a=i; continue; } } printf(\ \t\t是否继续删除? (y/n)); if(getch()=='y') deletebyname(); return; } if((i+1) { printf(\ \t\t是否继续删除相同姓名的用户信息? (y/n)); if(getch()=='y') { a=i; continue; } } } else continue; } if((deletemark==0)&&(findmark==0)) { printf(\ \t\t没有该用户的纪录); printf(\ \t\t是否继续删除? (y/n)); if(getch()=='y') deletebyphone(); return; return; } elseif(findmark! =0) { printf(\ \t\t没有重名信息); printf(\ \t\t没有该用户的纪录); printf(\ \t\t是否继续删除? (y/n)); if(getch()=='y') deletebyphone(); return; return; } } dele() { charchoic; printf(\ \t\t1-按电话号码删除2-按姓名删除); printf(\ \t\t请选择: ); choic=getch(); switch(choic) { case'1': deletebyphone();break; case'2': deletebyname();break; } return(0); } listbyname() { inti,j; structrecordtmp; for(i=1;i { if(strcmp(student[i].name,student[i-1].name)<0) { tmp=student[i]; j=i-1; do { student[j+1]=student[j]; j--; }while((strcmp(tmp.name,student[j].name)<0&&j>=0)); student[j+1]=tmp; } } printf(\ \t\t排序成功,是否显示? (y/n)); if(getch()=='y') list(); return(0); } save() { intj; FILE*fp; fp=fopen(student.txt,w); if(fp==NULL) printf(can'topenthefile.); if(num! =0) { for(j=0;j { fwrite(student,sizeof(student),1,fp); } } 牰湩晴尨保存成功! ); fclose(fp); return(0); }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 通讯录 管理 系统 源代码