通迅录.docx
《通迅录.docx》由会员分享,可在线阅读,更多相关《通迅录.docx(25页珍藏版)》请在冰豆网上搜索。
通迅录
通迅录.txt不要为旧的悲伤而浪费新的眼泪!
现在干什么事都要有经验的,除了老婆。
没有100分的另一半,只有50分的两个人。
#include
#include
#include
structfriends_list
{
charname[20];
intage;
chartelephone[13];
charaddress[30];
charQQ[11];
};
intcount=0;
voidnew_friend(structfriends_listfriends[]);
voidsearch_friend();
voidchazhao1();
voidchazhao2();
voidchazhao3();
voidchazhao4();
voidchazhao5();
intdel(intn);
voidpaixu();
voidpaixu1();
voidpaixu2();
voidpaixu3();
voidpaixu4();
voidpaixu5();
voidxiugai();
voidxianshi(intcount);
voidcuowu();
structfriends_listfriends[50];
intmain(void)
{
system("colorf9");
charmi[10]="qin123";
charm[10];
charna[10];
inti=0;
printf("\t\t\t请输入您的姓名:
\n\t\t\t");
gets(na);
for(i=0;i<3;i++)
{
printf("\t\t\t%s您好!
请输入密码:
\n\t\t\t",na);
gets(m);
if(strcmp(m,mi)==0)
{
printf("\t\t\t欢迎!
\n");
system("pause");
system("cls");
break;
}
if(strcmp(m,mi)!
=0)
printf("\t\t\t密码错误!
\n");
}
if(i>=3)
{
printf("\t\t\t结束\n");
exit(0);
}
intchoice;
charname[20];
do
{
system("color1d");
printf("\t***********************【通讯录信息管理系统】**********************\t\n\n");
printf("\t***********【【【制作人:
湖南工业大学通信103班--秦慧娟】】】*********\t\n\n");
printf("\t******************************【菜单】******************************\t\n");
printf("\t*****************************【1.新建】*****************************\t\n");
printf("\t*****************************【2.查询】*****************************\t\n");
printf("\t*****************************【3.删除】*****************************\t\n");
printf("\t****************************【4.排序】*****************************\t\n");
printf("\t****************************【5.修改】*****************************\t\n");
printf("\t************************【6.显示所有联系人】************************\t\n");
printf("\t***************************【0.安全退出】*****************************\t\n");
printf("请选择功能:
1-4\n\t\t\t");
scanf("%d",&choice);
switch(choice)
{
case1:
new_friend(friends);
break;
case2:
search_friend();
break;
case3:
count=del(count);
break;
case4:
paixu();
break;
case5:
xiugai();
break;
case6:
xianshi(count);
break;
case0:
break;
default:
cuowu();
break;
}
}while(choice!
=0);
printf("\t\t\t%s:
谢谢您使用通讯录功能!
\n\t\t\t",na);
printf("欢迎下次使用!
\n\t\t\t");
system("pause");
return0;
}
voidnew_friend(structfriends_listfriends[])/*新建联系人*/
{
system("color0c");
structfriends_listf;
if(count==50)
{
printf("\t\t\t通讯录已满!
\n\t\t\t");
return;
}
printf("\t\t\t请输入新联系人的姓名:
");
scanf("%s",f.name);
printf("\t\t\t请输入新联系人的年龄:
");
scanf("%d",&f.age);
printf("\t\t\t请输入新联系人的联系方式:
");
scanf("%s",f.telephone);
printf("\t\t\t请输入新联系人的QQ:
");
scanf("%s",f.QQ);
printf("\t\t\t请输入新联系人的地址:
");
scanf("%s",f.address);
friends[count]=f;
count++;
system("pause");
system("cls");
}
voidsearch_friend()/*查找联系人*/
{
system("cls");
system("color87");
if(count==0)
{
printf("\t\t\t通讯录是空的!
\n");
system("pause");
system("cls");
return;
}
else
{
ints;
printf("\t\t*************【【通讯录管理系统】】***************\n\n");
printf("\t\t**********按姓名查找请选1:
**********\n");
printf("\t\t**********按电话查找请选2:
**********\n");
printf("\t\t**********按年龄查找请选3:
**********\n");
printf("\t\t**********按QQ号查找请选4:
**********\n");
printf("\t\t**********按地址查找请选5:
**********\n\t\t\t\t");
printf("请选择功能:
1-4\n\t\t\t");
scanf("%d",&s);
switch(s)
{
case1:
chazhao1();/*按姓名对联系人排序*/
break;
case2:
chazhao2();
break;
case3:
chazhao3();
break;
case4:
chazhao4();
break;
case5:
chazhao5();
break;
default:
cuowu();
break;
}
}
}
voidchazhao1()/*按姓名查找联系人*/
{
system("color7A");
inti;
intflag=0;
charname[20];
printf("\t\t\t请输入要查找的联系人姓名:
");
scanf("%s",name);
for(i=0;iif(strcmp(name,friends[i].name)==0)
{
flag=1;
break;
}
if(flag)
{
printf("\n\t\t\t姓名:
%s\t",friends[i].name);
printf("\n\t\t\t年龄:
%d\t",friends[i].age);
printf("\n\t\t\t电话:
%s\t",friends[i].telephone);
printf("\n\t\t\tQQ:
%s\t",friends[i].QQ);
printf("\n\t\t\t地址:
%s\t",friends[i].address);
system("pause");
system("cls");
}
else
printf("\n\t\t\t无此联系人!
\n");
system("pause");
system("cls");
}
voidchazhao2()/*按电话查找联系人*/
{
system("color4F");
inti;
chartelephone[20];
printf("\t\t\t请输入要查找的联系人的电话:
");
scanf("%s",telephone);
for(i=0;i{
if(strcmp(telephone,friends[i].telephone)==0)
{
printf("\n\t\t\t姓名:
%s\t",friends[i].name);
printf("\n\t\t\t年龄:
%d\t",friends[i].age);
printf("\n\t\t\t电话:
%s\t",friends[i].telephone);
printf("\n\t\t\tQQ:
%s\t",friends[i].QQ);
printf("\n\t\t\t地址:
%s\t",friends[i].address);
system("pause");
system("cls");
break;
}
}
if(i>=count)
{
printf("\n\t\t\t无此联系人!
\n");
system("pause");
system("cls");
}
}
voidchazhao3()/*按联系人的年龄查找*/
{
system("color1F");
inti;
intage;
printf("\t\t\t请输入要查找的联系人的年龄:
");
scanf("%d",&age);
for(i=0;i{
if(age==friends[i].age)
{
printf("\n\t\t\t姓名:
%s\t",friends[i].name);
printf("\n\t\t\t年龄:
%d\t",friends[i].age);
printf("\n\t\t\t电话:
%s\t",friends[i].telephone);
printf("\n\t\t\tQQ:
%s\t",friends[i].QQ);
printf("\n\t\t\t地址:
%s\t",friends[i].address);
system("pause");
system("cls");
break;
}
}
if(i>=count)
{
printf("\n\t\t\t无此联系人!
\n");
system("pause");
system("cls");
}
}
voidchazhao4()/*按的QQ查找联系人*/
{
system("color3B");
inti;
chars[20];
printf("\t\t\t请输入您要查找的联系人的QQ:
");
scanf("%s",s);
for(i=0;i{
if(strcmp(s,friends[i].QQ)==0)
{
printf("\t\t\t姓名:
%s\n",friends[i].name);
printf("\n\t\t\t年龄:
%d\t",friends[i].age);
printf("\n\t\t\t电话:
%s\t",friends[i].telephone);
printf("\n\t\t\tQQ:
%s\t",friends[i].QQ);
printf("\n\t\t\t地址:
%s\t",friends[i].address);
system("pause");
system("cls");
break;
}
}
if(i>=count)
{
printf("\n\t\t\t无此联系人!
\n");
system("pause");
system("cls");
}
}
voidchazhao5()/*按地址查找联系人*/
{
system("color58");
inti;
chars[20];
printf("\t\t\t请输入您要查找的联系人的地址:
");
scanf("%s",s);
for(i=0;i{
if(strcmp(s,friends[i].address)==0)
{
printf("\t\t\t姓名:
%s\n",friends[i].name);
printf("\t\t\t年龄:
%d\t",friends[i].age);
printf("\n\t\t\t电话:
%s\t",friends[i].telephone);
printf("\n\t\t\tQQ:
%s\t",friends[i].QQ);
printf("\n\t\t\t地址:
%s\t",friends[i].address);
system("pause");
system("cls");
break;
}
}
if(i>=count)
{
printf("\n\t\t\t无此联系人!
\n");
system("pause");
system("cls");
}
}
intdel(intcount)/*删除联系人*/
{
system("cls");
system("color4e");
chars[20];
inti=0,j;
if(count==0)
{
printf("\t\t\t对不起!
你的通讯录中还没有联系人\n");
system("pause");
system("cls");
return0;
}
printf("\t\t\t请输入想删除联系人的姓名:
");
scanf("%s",s);
for(i=0;i{
if(strcmp(friends[i].name,s)==0)
{
for(j=i;j{
strcpy(friends[j].name,friends[j+1].name);
friends[j].age=friends[j+1].age;
strcpy(friends[j].telephone,friends[j+1].telephone);
strcpy(friends[j].QQ,friends[j+1].QQ);
strcpy(friends[j].address,friends[j+1].address);
}
printf("\t\t\t已经成功删除!
\n");
system("pause");
system("cls");
return(count-1);
}
}
if(i>=count)
printf("\t\t\t通讯录中没有此人!
");
system("pause");
system("cls");
returncount;
}
voidpaixu()/*对联系人进行排序*/
{
system("cls");
if(count==0)
{
printf("\t\t\t通讯录是空的!
\n");
system("pause");
system("cls");
return;
}
else
{
ints;
printf("\t\t*************【【通讯录管理系统】】***************\n\n");
printf("\t\t**********按姓名排序请选1:
**********\n");
printf("\t\t**********按年龄排序请选2:
**********\n");
printf("\t\t**********按QQ号排序请选3:
**********\n");
printf("\t\t**********按电话排序请选4:
**********\n");
printf("\t\t**********按地址排序请选5:
**********\n\t\t\t\t");
printf("请选择功能:
1-4\n\t\t\t");
scanf("%d",&s);
switch(s)
{
case1:
paixu1();
break;
case2:
paixu2();
break;
case3:
paixu3();
break;
case4:
paixu4();
break;
case5:
paixu5();
break;
default:
cuowu();
break;
}
}
}
voidpaixu1()
{
inti,m,n;
intj;
structfriends_listtemp;
if(count==0)
printf("\t\t\t通讯录是空的!
\n");
for(i=0;i{
for(j=i+1;j{
if(strcmp(friends[i].name,friends[j].name)>0)
{
temp=friends[i];
friends[i]=friends[j];
friends[j]=temp;
}
}
}
for(i=0;i{
printf("\t\t\t姓名:
%s\n",friends[i].name);
printf("\t\t\t年龄:
%d\n",friends[i].age);
printf("\t\t\t电话:
%s\n",friends[i].telephone);
printf("\t\t\tQQ号:
%s\n",friends[i].QQ);
printf("\t\t\t地址:
%s\n\n\n",friends[i].address);
}
printf("\t\t\t排序完成!
\n");
system("pause");
system("cls");
}
voidpaixu2()
{
inti;
intj;
intm;
intn;
structfriends_listtemp;
if(count==0)
printf("\t\t\t通讯录是空的!
\n");
for(i=0;i{
for(j=0;j{
if(friends[i].age>friends[j].age)
{
temp=friends[i];
friends[i]=friends[j];
friends[j]=temp;
}
}
}
for(i=0;i{
printf("\t\t\t姓名:
%s\n",friends[i].name);
printf("\t\t\t年龄:
%d\n",friends[i].age);
printf("\t\t\t电话:
%s\n",friends[i].telephone);
printf("\t\t\tQQ号:
%s\n",friends[i].QQ);
printf("\t\t\t地址:
%s\n\n\n",friends[i].address);
}
printf("\t\t\t排序完成!
\n");
system("pause");
system("cls");
}
voidpaixu3()
{
inti,j;
intm,n;
structfriends_listtemp;
if(count==0)
printf("\t\t\t通讯录是空的!
\n");
for(i=0;i{
for(j=i+1;j{
if(strcmp(friends[i].QQ,friends[j].QQ)>0)
{
temp=friends[i];
friends[j]=friends[i];
friends[j]=temp;
}
}
}
for(i=0;i{
printf("\t\t\t姓名:
%s\n",friends[i].name);