c语言学生通讯录管理系统

题目11:学生通讯录管理系统设计设计一个学生通信录,学生通迅录数据信息构成内容可自行设计(如:姓名、家庭地址、邮政编码、电话号码等等),通信录数据类型定义为结构体类型。1... 题目11:学生通讯录管理系统设计
设计一个学生通信录,学生通迅录数据信息构成内容可自行设计(如:姓名、家庭地址、邮政编码、电话号码等等),通信录数据类型定义为结构体类型。
1.主要功能:
(1) 能建立、修改和增删学生通讯录
(2) 能够按多种方式进行查询
2.要求:界面友好,易于操作,采用二进制文件存储数据。
需要word电子版的, 急急急,请各位大神帮帮忙!!!
展开
 我来答
宇落星辰dMH
推荐于2018-02-27 · TA获得超过181个赞
知道答主
回答量:115
采纳率:0%
帮助的人:121万
展开全部
/* HELLO.C -- Hello, world */

#include<stdio.h>
struct person
{
char name[8];
char tel[15];
char addr[50];
};
char filename[20]="E:\\txl.txt";
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void delete();
main( )

{
int m;
creat();
while(1)
{
printf("\n\t\t*********欢迎使用通讯录信息管理系统*********\n\n");
printf("\n\t\t添加,请按1");
printf("\n\t\t查找,请按2");
printf("\n\t\t修改,请按3");
printf("\n\t\t删除,请按4");
printf("\n\t\t输出,请按5");
printf("\n\t\t退出,请按0\n");
printf("\n\t\t********************************************\n\n");
printf("Please select(0--5):");
scanf("%d",&m);
if(m>=0&&m<=5)
{
switch(m)
{
case 1: append();
break;
case 2: search();
break;
case 3: modify();
break;
case 4: delete();
break;
case 5: output();
break;
case 0: exit();
}
printf("\n\n操作完毕,请再次选择!");
}
else
printf("\n\n选择错误,请再次选择!");
}
}

/*输入模块creat( ): 创建通讯录的子函数。*/
void creat()
{
struct person one;
long s1;
/*printf("\n请输入通讯录文件名:");
scanf("%s",filename); */

if((fp=fopen(filename,"at+"))==NULL)
{
printf("\n不能建立通讯录!");
exit();
}
fprintf(fp,"%-10s%-20s%-50s\n","姓名","电话号码","住址");
printf("\n请输入姓名、电话号码及住址(以0结束)\n");
scanf("%s",one.name);
while(strcmp(one.name,"0"))
{
scanf("%s%s",one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
scanf("%s",one.name);
}
fclose(fp);
}

/*输出模块output( ):输出通讯录中联系人通讯信息的子函数*/
void output()
{
struct person one;
if((fp=fopen(filename,"r"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n\n%20s\n","通 讯 录");
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
printf("%-10s%-20s%-50s",one.name,one.tel,one.addr);
}
fclose(fp);
}

/*添加模块append( ):向通讯录中添加某人通讯信息的子函数*/
void append()
{
struct person one;
if((fp=fopen(filename,"a"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n请输入添加的姓名、电话号码及住址\n");
scanf("%s%s%s",one.name,one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
fclose(fp);
}

/*查找模块search( ):在通讯录中查找某人通讯信息的子函数*/
void search()
{
int k=0;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
printf("\n\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
k=1;
}
}
if(!k)
printf("\n\n对不起,通讯簿中没有此人的记录。");
fclose(fp);
}

/*修改模块modify( ):在通讯录中修改某人通讯信息的子函数*/
void modify()
{
int m,k=0;
long offset;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n请输入新姓名、电话号码及住址:");
scanf("%s%s%s",one.name,one.tel,one.addr);
fseek(fp,offset,SEEK_SET);
printf("%ld",ftell(fp));
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}

/*删除模块delete( ):在通讯录中删除某人通讯信息的子函数*/
void delete()
{
int m,k=0,flag;
long offset1,offset2;
char namekey[8], valid[4];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset1=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
if(k)
{
printf("\n已查到,记录为");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n确实要删除,按1;不删除,按0:");
scanf("%d",&m);
if(m)
{
fseek(fp,offset1,SEEK_SET);
fprintf(fp,"%-10s%-20s%-50s\n","","","");
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}
}
}
}
<PIXTEL_MMI_EBOOK_2005>1###########################################################</PIXTEL_MMI_EBOOK_2005>
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
法本信息技术
2024-10-28 广告
在深圳市法本信息技术股份有限公司,软件测试开发是确保软件质量的关键环节。我们专注于设计高效测试用例,利用自动化测试工具与框架,对软件进行全方位、多层次的测试。这包括单元测试、集成测试、系统测试及验收测试,旨在发现并修复潜在缺陷,提升软件稳定... 点击进入详情页
本回答由法本信息技术提供
手机用户40092
2014-06-20 · 超过45用户采纳过TA的回答
知道答主
回答量:150
采纳率:0%
帮助的人:98.8万
展开全部
/* HELLO.C -- Hello, world */

#include<stdio.h>
struct person
{
char name[8];
char tel[15];
char addr[50];
};
char filename[20]="E:\\txl.txt";
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void delete();
main( )

{
int m;
creat();
while(1)
{
printf("\n\t\t*********欢迎使用通讯录信息管理系统*********\n\n");
printf("\n\t\t添加,请按1");
printf("\n\t\t查找,请按2");
printf("\n\t\t修改,请按3");
printf("\n\t\t删除,请按4");
printf("\n\t\t输出,请按5");
printf("\n\t\t退出,请按0\n");
printf("\n\t\t********************************************\n\n");
printf("Please select(0--5):");
scanf("%d",&m);
if(m>=0&&m<=5)
{
switch(m)
{
case 1: append();
break;
case 2: search();
break;
case 3: modify();
break;
case 4: delete();
break;
case 5: output();
break;
case 0: exit();
}
printf("\n\n操作完毕,请再次选择!");
}
else
printf("\n\n选择错误,请再次选择!");
}
}

/*输入模块creat( ): 创建通讯录的子函数。*/
void creat()
{
struct person one;
long s1;
/*printf("\n请输入通讯录文件名:");
scanf("%s",filename); */

if((fp=fopen(filename,"at+"))==NULL)
{
printf("\n不能建立通讯录!");
exit();
}
fprintf(fp,"%-10s%-20s%-50s\n","姓名","电话号码","住址");
printf("\n请输入姓名、电话号码及住址(以0结束)\n");
scanf("%s",one.name);
while(strcmp(one.name,"0"))
{
scanf("%s%s",one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
scanf("%s",one.name);
}
fclose(fp);
}

/*输出模块output( ):输出通讯录中联系人通讯信息的子函数*/
void output()
{
struct person one;
if((fp=fopen(filename,"r"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n\n%20s\n","通 讯 录");
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
printf("%-10s%-20s%-50s",one.name,one.tel,one.addr);
}
fclose(fp);
}

/*添加模块append( ):向通讯录中添加某人通讯信息的子函数*/
void append()
{
struct person one;
if((fp=fopen(filename,"a"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n请输入添加的姓名、电话号码及住址\n");
scanf("%s%s%s",one.name,one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
fclose(fp);
}

/*查找模块search( ):在通讯录中查找某人通讯信息的子函数*/
void search()
{
int k=0;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
printf("\n\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
k=1;
}
}
if(!k)
printf("\n\n对不起,通讯簿中没有此人的记录。");
fclose(fp);
}

/*修改模块modify( ):在通讯录中修改某人通讯信息的子函数*/
void modify()
{
int m,k=0;
long offset;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n请输入新姓名、电话号码及住址:");
scanf("%s%s%s",one.name,one.tel,one.addr);
fseek(fp,offset,SEEK_SET);
printf("%ld",ftell(fp));
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}

/*删除模块delete( ):在通讯录中删除某人通讯信息的子函数*/
void delete()
{
int m,k=0,flag;
long offset1,offset2;
char namekey[8], valid[4];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset1=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
if(k)
{
printf("\n已查到,记录为");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n确实要删除,按1;不删除,按0:");
scanf("%d",&m);
if(m)
{
fseek(fp,offset1,SEEK_SET);
fprintf(fp,"%-10s%-20s%-50s\n","","","");
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}
}
}
}
<PIXTEL_MMI_EBOOK_2005>1###########################################################</PIXTEL_MMI_EBOOK_2005>
追问
我现在手里有一份文字版的,能不能传上图片你给我弄成电子版的??!!小学期验收答辩需要,帮帮忙!!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
尤物mOg
2014-06-20 · 超过57用户采纳过TA的回答
知道答主
回答量:118
采纳率:50%
帮助的人:104万
展开全部
/* HELLO.C -- Hello, world */

#include<stdio.h>
struct person
{
char name[8];
char tel[15];
char addr[50];
};
char filename[20]="E:\\txl.txt";
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void delete();
main( )

{
int m;
creat();
while(1)
{
printf("\n\t\t*********欢迎使用通讯录信息管理系统*********\n\n");
printf("\n\t\t添加,请按1");
printf("\n\t\t查找,请按2");
printf("\n\t\t修改,请按3");
printf("\n\t\t删除,请按4");
printf("\n\t\t输出,请按5");
printf("\n\t\t退出,请按0\n");
printf("\n\t\t********************************************\n\n");
printf("Please select(0--5):");
scanf("%d",&m);
if(m>=0&&m<=5)
{
switch(m)
{
case 1: append();
break;
case 2: search();
break;
case 3: modify();
break;
case 4: delete();
break;
case 5: output();
break;
case 0: exit();
}
printf("\n\n操作完毕,请再次选择!");
}
else
printf("\n\n选择错误,请再次选择!");
}
}

/*输入模块creat( ): 创建通讯录的子函数。*/
void creat()
{
struct person one;
long s1;
/*printf("\n请输入通讯录文件名:");
scanf("%s",filename); */

if((fp=fopen(filename,"at+"))==NULL)
{
printf("\n不能建立通讯录!");
exit();
}
fprintf(fp,"%-10s%-20s%-50s\n","姓名","电话号码","住址");
printf("\n请输入姓名、电话号码及住址(以0结束)\n");
scanf("%s",one.name);
while(strcmp(one.name,"0"))
{
scanf("%s%s",one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
scanf("%s",one.name);
}
fclose(fp);
}

/*输出模块output( ):输出通讯录中联系人通讯信息的子函数*/
void output()
{
struct person one;
if((fp=fopen(filename,"r"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n\n%20s\n","通 讯 录");
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
printf("%-10s%-20s%-50s",one.name,one.tel,one.addr);
}
fclose(fp);
}

/*添加模块append( ):向通讯录中添加某人通讯信息的子函数*/
void append()
{
struct person one;
if((fp=fopen(filename,"a"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
printf("\n请输入添加的姓名、电话号码及住址\n");
scanf("%s%s%s",one.name,one.tel,one.addr);
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
fclose(fp);
}

/*查找模块search( ):在通讯录中查找某人通讯信息的子函数*/
void search()
{
int k=0;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"rb"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
printf("\n\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
k=1;
}
}
if(!k)
printf("\n\n对不起,通讯簿中没有此人的记录。");
fclose(fp);
}

/*修改模块modify( ):在通讯录中修改某人通讯信息的子函数*/
void modify()
{
int m,k=0;
long offset;
char namekey[8];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
}
}
if(k)
{
printf("\n已查到,记录为:");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n请输入新姓名、电话号码及住址:");
scanf("%s%s%s",one.name,one.tel,one.addr);
fseek(fp,offset,SEEK_SET);
printf("%ld",ftell(fp));
fprintf(fp,"%-10s%-20s%-50s\n",one.name,one.tel,one.addr);
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}

/*删除模块delete( ):在通讯录中删除某人通讯信息的子函数*/
void delete()
{
int m,k=0,flag;
long offset1,offset2;
char namekey[8], valid[4];
struct person one;
printf("\n请输入姓名:");
scanf("%s",namekey);
if((fp=fopen(filename,"r+"))==NULL)
{
printf("\n不能打开通讯录!");
exit();
}
while(!feof(fp))
{
offset1=ftell(fp);
fscanf(fp,"%s%s%s\n",one.name,one.tel,one.addr);
if(!strcmp(namekey,one.name))
{
k=1;
break;
if(k)
{
printf("\n已查到,记录为");
printf("\n%-10s%-18s%-50s",one.name,one.tel,one.addr);
printf("\n确实要删除,按1;不删除,按0:");
scanf("%d",&m);
if(m)
{
fseek(fp,offset1,SEEK_SET);
fprintf(fp,"%-10s%-20s%-50s\n","","","");
}
else
printf("\n对不起,通讯录中没有此人的记录。");
fclose(fp);
}
}
}
}
<PIXTEL_MMI_EBOOK_2005>1###########################################################</PIXTEL_MMI_EBOOK_2005>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
星月小木木
2015-12-16 · TA获得超过3.2万个赞
知道大有可为答主
回答量:2.4万
采纳率:0%
帮助的人:9490万
展开全部
//简单的学生通讯录管理系统
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
struct record
{
char name[20]; //姓名
char phone[12]; //电话
char adress[50]; //地址
char postcode[8]; //邮政编码
char e_mail[20]; //电子邮件。
}student[100]; //假设最大数为100.
//定义全局变量num,表示已经输入的人数 。
int num; //这里使用数组解决通讯录的问题,实际上使用链表更好。
int menu_select()
{
char s[80];
int a;/*定义整形变量*/
system("cls");
printf("\t\t***********欢迎进入通讯管理界面********\n\n");
printf("\t\t\t0. 输入记录\n");
printf("\t\t\t1. 显示记录\n");
printf("\t\t\t2. 按姓名查找\n");
printf("\t\t\t3. 按电话号码查找\n");
printf("\t\t\t4. 插入记录 \n");
printf("\t\t\t5. 按姓名排序\n");
printf("\t\t\t6. 删除记录\n");
printf("\t\t\t7. Quit\n");
printf("\t\t***********************************************\n\n");
do{
printf("Enter you choice(0~7):");
scanf("%s",s);
a=atoi(s);
}
while (a<0 || a>7);
return a;
}
int adduser()
{
printf("\t\t\t**************** 请输入用户信息 ****************\n");
printf("\t\t\t输入姓名:\n");
scanf("%s",student[num].name);
printf("\t\t\t输入电话号码:\n");
scanf("%s",student[num].phone);
printf("\t\t\t输入地址:\n");
scanf("%s",student[num].adress);
printf("\t\t\t输入邮编:\n");
scanf("%s",student[num].postcode);
printf("\t\t\t输入e-mail:\n");
scanf("%s",student[num].e_mail);
num++;
printf("\t\t\t是否继续添加?(Y/N):\n");
if(getch()=='y' || getch()=='Y')
adduser();
return(0);
}
void list()
{
int i;
system("cls");
if(num!=0)
{
printf("\t\t\t*************** 以下为通讯录所有信息************\n");
for (i=0;i<num;i++)
{
printf("\t\t\t姓名:%s\n",student[i].name);
printf("\t\t\t电话:%s\n",student[i].phone);
printf("\t\t\t地址:%s\n",student[i].adress);
printf("\t\t\t邮编:%s\n",student[i].postcode);
printf("\t\t\te-mail:%s\n",student[i].e_mail);
if(i+1<num)
{
system("pause");
}
}
printf("\t\t\t************************************************\n");
}
else
printf("\t\t\t通讯录中无任何纪录\n");
printf("\t\t\t按任意键返回主菜单:\n");
getch(); //这里是无回显的输入字符,你输入的字符不会显示在屏幕上。
return;
}
int searchbyname()
{
int mark=0;
int i;
printf("\t\t\t***************** 按姓名查找 *******************\n");
char name[20];
printf("\t\t\t请输入姓名:\n");
scanf("%s",name);
for(i=0;i<num;i++)
{
if (strcmp(student[i].name,name)==0)
{
printf("\t\t\t************* 以下是您查找的用户信息 ***********\n");
printf("\t\t\t姓名: %s",student[i].name);
printf("\t\t\t电话: %s",student[i].phone);
printf("\t\t\t地址: %s",student[i].adress);
printf("\t\t\te-mail:%s",student[i].e_mail);
printf("\t\t\t************************************************\n");
mark++;
if((i+1)<num)
{
printf("\t\t\t是否继续查找相同名字的用户信息:(y/n)\n");
if(getch()=='y' || getch()=='Y')
{
continue;
}
else
return(0);
}
else
{
printf("\t\t\t按任意键返回主菜单");
getch();
return(0);
}
}
}
if(mark == 0)
{
printf("\t\t\t没有相同姓名的用户纪录\n");
printf("\t\t\t按任意键返回主菜单\n");
getch();
return(0);
}
return 0;
}
int searchbyphone()
{
int mark=0;
int i;
printf("\t\t\t****************** 按电话查找 ******************\n");
char phone[10];
printf("\t\t\t请输入电话号码:\n");
scanf("%s",phone);
for(i=0;i<num;i++)
{
if (strcmp(student[i].phone,phone)==0)
{
printf("\t\t\t************** 以下是您查找的用户信息 **********\n");
printf("\t\t\t姓名: %s",student[i].name);
printf("\t\t\t电话: %s",student[i].phone);
printf("\t\t\t地址: %s",student[i].adress);
printf("\t\t\te-mail:%s",student[i].e_mail);
printf("\t\t\t************************************************\n");
printf("\t\t\t按任意键返回主菜单\n");
mark++;
getch();
return(0);
}
}
if (mark==0)
{
printf("\t\t\t没有改用户的信息\n");
printf("\t\t\t按任意键返回主菜单\n");
getch();
return(0);
}
return(0);
}
void deletebyphone()
{
int i,j;
int deletemark=0;
char phone[20];
printf("\t\t\t请输入要删除用户电话号码:\n");
scanf("%s",phone);
if(num==0)
{
printf("\t\t\t对不起,文件中无任何纪录\n");
printf("\t\t\t按任意键返回主菜单\n");
getch();
return;
}
for (i=0;i<num;i++)
{
if (strcmp(student[i].phone,phone)==0)
{
printf("\t\t\t以下是您要删除的用户纪录:\n");
printf("\t\t\t姓名: %s",student[i].name);
printf("\t\t\t电话: %s",student[i].phone);
printf("\t\t\t地址: %s",student[i].adress);
printf("\t\t\te-mail:%s",student[i].e_mail);
printf("\t\t\t是否删除?(y/n)");
if (getch()=='y' || getch()=='Y')
{
for (j=i;j<num-1;j++)
student[j]=student[j+1];
num--;
deletemark++;
printf("\t\t\t删除成功");
printf("\t\t\t是否继续删除?(y/n)");
if (getch()=='y' || getch()=='Y')
deletebyphone();
return;
}
else
return;
}
continue;
}
if (deletemark==0)
{
printf("\t\t\t没有该用户的纪录");
printf("\t\t\t是否继续删除?(y/n)");
if(getch()=='y' || getch()=='Y')
deletebyphone();
return;
}
return;
}
void deletebyname()
{
int a=0;
int findmark=0;
int j;
int deletemark=0;
int i;
char name[20];
printf("\t\t\t请输入要删除用户姓名:\n");
scanf("%s",name);
for (i=a;i<num;i++)
{
if(strcmp(student[i].name,name)==0)
{
printf("\t\t\t以下是您要删除的用户纪录:");
findmark++;
printf("\t\t\t________________________________");
printf("\t\t\t姓名: %s",student[i].name);
printf("\t\t\t电话: %s",student[i].phone);
printf("\t\t\t地址: %s",student[i].adress);
printf("\t\t\te-mail:%s",student[i].e_mail);
printf("\t\t\t________________________________");
printf("\t\t\t是否删除?(y/n)");
if (getch()=='y' || getch() == 'Y')
{
for(j=i;j<num-1;j++)
student[j]=student[j+1];
num--;
deletemark++;
printf("\t\t\t删除成功");
if((i+1)<num)
{
printf("\t\t\t是否继续删除相同姓名的用户信息?(y/n)");
if (getch()=='y')
{
a=i;
continue;
}
}
printf("\t\t\t是否继续删除?(y/n)");
if (getch()=='y')
deletebyname();
return;
}
if((i+1)<num)
{
printf("\t\t\t是否继续删除相同姓名的用户信息?(y/n)");
if (getch()=='y' || getch() == 'Y')
{
a=i;
continue;
}
}
}
else
continue;
}
if ((deletemark==0)&&(findmark==0))
{
printf("\t\t\t没有该用户的纪录");
printf("\t\t\t是否继续删除?(y/n)");
if(getch()=='y' || getch() == 'Y')
deletebyphone();
return;
}
else if (findmark!=0)
{
printf("\t\t\t没有重名信息");
printf("\t\t\t没有该用户的纪录");
printf("\t\t\t是否继续删除?(y/n)");
if(getch()=='y' || getch() == 'Y')
deletebyphone();
return;
}
}
int dele()
{
char choic;
printf("\t\t\t1-按电话号码删除 2-按姓名删除");
printf("\t\t\t请选择:");
choic=getch();
switch (choic)
{
case '1':deletebyphone();break;
case '2':deletebyname();break;
}
return(0);
}
int sortbyname() //按姓名进行排序
{
int i,j;
struct record tmp;
for (i=1;i<num;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\t排序成功,是否显示?(y/n)");
if (getch()=='y')
list();
return(0);
}
int main()
{
printf("\t\t************************************************\n");
printf("\t\t********welcome to TONGXUNLU *******************\n");
printf("\t\t###########code by XXXXX ###################\n");
printf("\t\t*************************************************\n");
printf("按任意键进入主菜单\n");
getch();
int selectnum;
while(1)
{
selectnum = menu_select();
switch(selectnum)
{
case 0:
{
adduser();
break;
}
case 1:
{
list();
break;
}
case 2:
{
searchbyname();
break;
}
case 3:
{
searchbyphone();
break;
}
case 4:
{
adduser(); //这里插入,应该能指定位置,不过意义不大,所以和添加记录一样了。
break;
}
case 5:
{
sortbyname();
break;
}
case 6:
{
dele();
break;
}
case 7:
{
printf("BYE BYE!\n");
system("pause");
getchar();
exit(0);
}
}
}
getchar();
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式