C语言-通讯录管理系统
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
printf(" *******通讯录信息查询*******\n");
printf(" ******************************\n");
find_record(flag);
break;
case 4:
printf(" ***********************************\n");
{ printf("学号(12)姓名(10)出生年月(10)家庭住址(30)邮编(10)电话(15) \n");
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday,data[i].post, data[i].phone);
printf(" ------------------------------\n");
printf("\t\t\t是否删除?(y/n)");
if (getch()=='y' || getch()=='Y')
{
for (j=i;j<flag-1;j++)
data[j]=data[j+1];
flag--;
if(i==1)
{for (i=1;i<flag;i++)
{
if(strcmp(data[i].name, data [i-1].name)<0)
{
tmp= data[i];
j=i-1;
do
{
data [j+1]= data [j];
j--;
}while ((strcmp(tmp.name, data [j].name)<0&&j>=0));
printf(" ***********************************************\n");
flag=create_record();
break;
case 2:
printf(" ***********************************************\n");
}
}
int menu_select()
{
int i;
printf(" ******************** \n");
printf(" Welcome! \n ");
printf(" Form kuangmin\n");
printf(" ******************** \n");
printf(" \n");
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
}
}
int save_record(int flag)
{
FILE*fp;
int i;
if ((fp=fopen("D:\\data.txt","w+"))==NULL)
int save_record(int flag);
void main()
{
for( ; ; ){
switch(menu_select())
{
case 1:
printf(" ***********************************************\n");
printf(" **************通讯录的建立***************\n");
int menu_select( );
int create_record();
int add_record(int flag);
int flag=0;
int find_record(int flag);
int delete_record(int flag);
void paixu_record(int flag);
data [j+1]=tmp;
}
}
printf("\t\t\t排序成功! ");}
if(i==2)
{for(j=0;j<flag;j++)
for(i=0;i<flag-j;i++)
if(data[i].num>data[i+1].num)
{tmp=data[i]; data[i]=data[i+1];data[i+1]=tmp;}
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday, data[i].post, data[i].phone);
printf(" **********通讯者的排序*********\n");
printf(" ***********************************\n");
paixu_record(flag);
break;
case 0:
printf("\t谢谢您的使用!\n");
break;
default : break;}
i++;
printf("想继续添加吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,添加成功!请继续添加!\n");
}
return (i);
}
int find_record()
{
int i;
char number[6];
char named[10];
int xz;
printf("--------------------\n");
printf(" 1.按学号查询\n");
printf(" 2.按姓名查询\n");
printf("--------------------\n");
printf("请选择: \n");
scanf("%d",&xz);
if (xz==1){
printf(" **********通讯录的存储(D:\)*********\n");
printf(" ***********************************\n");
save_record(flag);
break;
case 6:
printf(" ***********************************\n");
printf(" **************通讯录信息的添加*****************\n");
printf(" ***********************************************\n");
flag=add_record(flag);
break;
case 3:
printf(" ******************************\n");
deletemark++;
printf("\t\t\t删除成功");
printf("\t\t\t是否继续删除?(y/n)");
if (getch()=='y' || getch()=='Y')
delete_record(flag);
return;
}
else
retu来自百度文库n;
}
continue;
}
if (deletemark==0)
printf(" \n");
printf(" \n");
printf("通讯录管理系统\n");
printf(" \n");
printf(" ======================\n");
printf(" 1.通讯录的建立\n");
printf(" 2.通讯者的添加\n");
printf(" 3.通讯录的查询\n");
char number[20];
printf("\t\t\t请输入要删除学号:\n");
scanf("%s",number);
for (i=0;i<flag;i++)
{
if (strcmp(data[i].num, number)==0)
{
printf("\t\t\t以下是您要删除的用户纪录:\n");
printf(" ------------------------------\n");
return 0;
}
else {printf("对不起,没有你要找的人! \n");return 0;}
}
}
int delete_record(int flag)
{
int i,j;
int deletemark=0;
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf("请输入要查找的学号:");
scanf("%s",number);
for(i=0;i<flag;i++)
if(strcmp(data[i].num,number)==0)
{
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct record{
char num[12];
char name[10];
char birthday[10];
char post[10];
char phone[15];
}data[100];
i++;
printf("想继续创建吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,创建成功!请继续创建!\n");
}
return i;
}
int add_record(int flag)
{ int i=flag,j;
for(i;;)
printf(" 4.通讯者的删除\n");
printf(" 5.通讯录的存储\n");
printf(" 6.通讯者的排序\n");
printf(" 0.退出通讯录管理系统\n");
printf(" ======================\n");
printf( "请选择操作0-5 \n\n");
printf(" **********通讯信息的删除***********\n");
printf(" ***********************************\n");
delete_record(flag);
break;
case 5:
printf(" ***********************************\n");
{
printf("\t\t\t没有该用户的纪录");
return;
}
return;
}
void paixu_record(int flag)
{int i,j;
struct record tmp;
printf(" 1.按姓名排序\n");
printf(" 2.按学号排序\n");
scanf("%d",&i);
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf(" ------------------------------\n");
return 0;
for(; ;)
{
scanf("%d",&i);
if(i<0||i>6)
printf("\t对不起,您的输入错误\n");
else
break;
}
return i;
}
int create_record()
{int i,j;
for(i=0;;)
{ printf("学号(12)姓名(10)出生年月(10)家庭住址(30)邮编(10)电话(15) \n");
}
else {printf("对不起,没有你要找的人! \n");return 0;}
}
else
if(xz=2){
printf("请输入要查找的姓名: ");
scanf("%s",named);
for(i=0;i<flag;i++)
if(strcmp(data[i].name,named)==0)
{
printf(" ******************************\n");
find_record(flag);
break;
case 4:
printf(" ***********************************\n");
{ printf("学号(12)姓名(10)出生年月(10)家庭住址(30)邮编(10)电话(15) \n");
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday,data[i].post, data[i].phone);
printf(" ------------------------------\n");
printf("\t\t\t是否删除?(y/n)");
if (getch()=='y' || getch()=='Y')
{
for (j=i;j<flag-1;j++)
data[j]=data[j+1];
flag--;
if(i==1)
{for (i=1;i<flag;i++)
{
if(strcmp(data[i].name, data [i-1].name)<0)
{
tmp= data[i];
j=i-1;
do
{
data [j+1]= data [j];
j--;
}while ((strcmp(tmp.name, data [j].name)<0&&j>=0));
printf(" ***********************************************\n");
flag=create_record();
break;
case 2:
printf(" ***********************************************\n");
}
}
int menu_select()
{
int i;
printf(" ******************** \n");
printf(" Welcome! \n ");
printf(" Form kuangmin\n");
printf(" ******************** \n");
printf(" \n");
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
}
}
int save_record(int flag)
{
FILE*fp;
int i;
if ((fp=fopen("D:\\data.txt","w+"))==NULL)
int save_record(int flag);
void main()
{
for( ; ; ){
switch(menu_select())
{
case 1:
printf(" ***********************************************\n");
printf(" **************通讯录的建立***************\n");
int menu_select( );
int create_record();
int add_record(int flag);
int flag=0;
int find_record(int flag);
int delete_record(int flag);
void paixu_record(int flag);
data [j+1]=tmp;
}
}
printf("\t\t\t排序成功! ");}
if(i==2)
{for(j=0;j<flag;j++)
for(i=0;i<flag-j;i++)
if(data[i].num>data[i+1].num)
{tmp=data[i]; data[i]=data[i+1];data[i+1]=tmp;}
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday, data[i].post, data[i].phone);
printf(" **********通讯者的排序*********\n");
printf(" ***********************************\n");
paixu_record(flag);
break;
case 0:
printf("\t谢谢您的使用!\n");
break;
default : break;}
i++;
printf("想继续添加吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,添加成功!请继续添加!\n");
}
return (i);
}
int find_record()
{
int i;
char number[6];
char named[10];
int xz;
printf("--------------------\n");
printf(" 1.按学号查询\n");
printf(" 2.按姓名查询\n");
printf("--------------------\n");
printf("请选择: \n");
scanf("%d",&xz);
if (xz==1){
printf(" **********通讯录的存储(D:\)*********\n");
printf(" ***********************************\n");
save_record(flag);
break;
case 6:
printf(" ***********************************\n");
printf(" **************通讯录信息的添加*****************\n");
printf(" ***********************************************\n");
flag=add_record(flag);
break;
case 3:
printf(" ******************************\n");
deletemark++;
printf("\t\t\t删除成功");
printf("\t\t\t是否继续删除?(y/n)");
if (getch()=='y' || getch()=='Y')
delete_record(flag);
return;
}
else
retu来自百度文库n;
}
continue;
}
if (deletemark==0)
printf(" \n");
printf(" \n");
printf("通讯录管理系统\n");
printf(" \n");
printf(" ======================\n");
printf(" 1.通讯录的建立\n");
printf(" 2.通讯者的添加\n");
printf(" 3.通讯录的查询\n");
char number[20];
printf("\t\t\t请输入要删除学号:\n");
scanf("%s",number);
for (i=0;i<flag;i++)
{
if (strcmp(data[i].num, number)==0)
{
printf("\t\t\t以下是您要删除的用户纪录:\n");
printf(" ------------------------------\n");
return 0;
}
else {printf("对不起,没有你要找的人! \n");return 0;}
}
}
int delete_record(int flag)
{
int i,j;
int deletemark=0;
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf("请输入要查找的学号:");
scanf("%s",number);
for(i=0;i<flag;i++)
if(strcmp(data[i].num,number)==0)
{
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct record{
char num[12];
char name[10];
char birthday[10];
char post[10];
char phone[15];
}data[100];
i++;
printf("想继续创建吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,创建成功!请继续创建!\n");
}
return i;
}
int add_record(int flag)
{ int i=flag,j;
for(i;;)
printf(" 4.通讯者的删除\n");
printf(" 5.通讯录的存储\n");
printf(" 6.通讯者的排序\n");
printf(" 0.退出通讯录管理系统\n");
printf(" ======================\n");
printf( "请选择操作0-5 \n\n");
printf(" **********通讯信息的删除***********\n");
printf(" ***********************************\n");
delete_record(flag);
break;
case 5:
printf(" ***********************************\n");
{
printf("\t\t\t没有该用户的纪录");
return;
}
return;
}
void paixu_record(int flag)
{int i,j;
struct record tmp;
printf(" 1.按姓名排序\n");
printf(" 2.按学号排序\n");
scanf("%d",&i);
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf(" ------------------------------\n");
return 0;
for(; ;)
{
scanf("%d",&i);
if(i<0||i>6)
printf("\t对不起,您的输入错误\n");
else
break;
}
return i;
}
int create_record()
{int i,j;
for(i=0;;)
{ printf("学号(12)姓名(10)出生年月(10)家庭住址(30)邮编(10)电话(15) \n");
}
else {printf("对不起,没有你要找的人! \n");return 0;}
}
else
if(xz=2){
printf("请输入要查找的姓名: ");
scanf("%s",named);
for(i=0;i<flag;i++)
if(strcmp(data[i].name,named)==0)
{