资源描述:
《c语言编写的通讯录代码、》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#includestructfriends_list{charname[10];intage;chartelephone[13];};intCount=0;voidnew_friend(structfriends_listfriends[]);voidsearch_friend(structfriends_listfriends[],char*name);voidModify_friend(structfriends_listfriends[],char*name);voidDelete_friend(structfr
2、iends_listfriends[],char*name,intn);intmain(void){intchoice,n;charname[10];structfriends_listfriends[50];do{printf("手机通讯录功能选项:1:新建2:查询3:修改4:删除0:退出");printf("请选择功能:");scanf("%d",&choice);switch(choice){case1:new_friend(friends);break;case2:printf("请输入要查找的联系人姓名:");scanf("%s",name);search_
3、friend(friends,name);break;case3:printf("请输入您要修改的联系人的姓名:"); scanf("%s",name);printf("");Modify_friend(friends,name);break;case4:printf("1:单个删除2:全部删除");printf("请选择您需要的操作:");scanf("%d",&n);if(n==1){printf("输入名字");scanf("%s",name); Delete_friend(friends,name,n);break;}if(n==2){Dele
4、te_friend(friends,name,n);break;}case0:break;}}while(choice!=0);printf("谢谢使用通讯录功能!");return0;}voidnew_friend(structfriends_listfriends[]){structfriends_listf;if(Count==50){printf("通讯录已满!");return;}printf("请输入新的联系人的姓名:");scanf("%s",f.name);printf("请输入新联系人的年龄:");scanf("%d",&f.age);print
5、f("请输入新联系人的联系电话:");scanf("%s",f.telephone);friends[Count]=f;Count++;}/*查询联系人*/voidsearch_friend(structfriends_listfriends[],char*name){inti,flag=0;if(Count==0){printf("通讯录是空的!");return;}/*在书本源代码的基础上,我修改了一下,让程序可以查询多个相同名字的联系人*/for(i=0;i6、("姓名:%st",friends[i].name);printf("年龄:%dt",friends[i].age);printf("电话:%s",friends[i].telephone);flag++;}if(flag==0) printf("无此联系人!");}/*修改联系人*/voidModify_friend(structfriends_listfriends[],char*name){intk,y=0;intt,j=1,g=0;structfriends_listx;if(Count==0){printf("通讯录是空的!");return;}
7、/*首先,判断要修改的联系人中有没有相同的名字*/for(k=0;k