From 97639c3e472bcdfd5b453d57bab85e11a479f946 Mon Sep 17 00:00:00 2001 From: 18408001239 <3145926128@qq.com> Date: Fri, 11 Jan 2019 16:12:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=94=90=E9=9B=84=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- txl.c | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 txl.c diff --git a/txl.c b/txl.c new file mode 100644 index 0000000..f2d3a96 --- /dev/null +++ b/txl.c @@ -0,0 +1,211 @@ +#include +#include +#include +#define N 80 +typedef struct +{ + char num[N]; + char name[20]; + char tele[15]; + char add[20]; + char emal[15]; +}STUDENT; +STUDENT stu[N] ; +int menu(); +int shuru(STUDENT stu[N]); +void xianshi(STUDENT stu[],int n); +int shanchu(STUDENT stu[],int n); +void chazhao(STUDENT stu[],int n); +void xiugai(STUDENT stu[],int n); +int tianjia(STUDENT stu[],int n); +int tuichu(); +int main() +{ + int length,m=0; + while(m>=0) + { + switch (menu()) + { + case 0:length=shuru(stu);break; + case 1: xianshi(stu,length);break; + case 2:length=shanchu(stu,length);break; + case 3:chazhao(stu,length);break; + case 4:xiugai(stu,length);break; + case 5:length=tianjia(stu,length);break; + case 6:m=tuichu();break; + default:printf("输入错误,请重新输入\n"); + } + } +} +int menu() +{ + int m; + printf(" 欢迎使用通讯录管理系统 \n"); + printf(" 主菜单 \n"); + printf("\t\t\t 0.输入通讯录\n"); + printf("\t\t\t 1.显示通讯录\n"); + printf("\t\t\t 2.删除通讯录\n"); + printf("\t\t\t 3.查找通讯录\n"); + printf("\t\t\t 4.修改通讯录\n"); + printf("\t\t\t 5.添加通讯录\n"); + printf("\t\t\t 6.退出通讯录\n"); + do{ + printf("\t\t\t 请输入选项0-6\n"); + scanf("%d",&m); + }while(m<0||m>6); + return m; +} +int shuru(STUDENT stu[N]) +{ + int i,n; + printf("\n请输入要加入通讯录的数目 \n"); + scanf("%d",&n); + printf("请输入信息 \n"); + for(i=0;in-1) + { + printf("没有找到要删除的记录,是否重新输入1/0(1代表是,0代表否)\n"); + scanf("%d",&ch); + if(ch==1) + n=shanchu(stu,n); + } + else + { + printf("编号:%s\n姓名:%s\n电话:%s\n地址:%s\nemal:%s\n",stu[i].num,stu[i].name,stu[i].tele,stu[i].add,stu[i].emal); + printf("是否确定要删除:%d是%2d否\n",1,0); + } + scanf("%d",&ch); + if(ch==1) + { + for(j=i+1;jn-1) + printf("没有找到要查找的记录,是否重新输入1/0\n"); + scanf("%d",&ch); + if(ch==1) + chazhao(stu,n); + else + printf("编号:%s\n姓名:%s\n电话:%s\n地址:%s\nemal:%s\n",stu[i].num,stu[i].name,stu[i].tele,stu[i].add,stu[i].emal); +} +void xiugai(STUDENT stu[],int n) +{ + int i,ch; + i=find(stu,n); + if(i>n-1) + { + printf("没有找到要修改的记录,是否重新输入1/0\n"); + scanf("%d",&ch); + if(ch==1) + xiugai(stu,n); + } + else + { + printf("编号:%s\n姓名:%s\n电话:%s\n地址:%s\nemal:%s\n",stu[i].num,stu[i].name,stu[i].tele,stu[i].add,stu[i].emal); + printf("是否确定要修改:%d是%2d否\n",1,0); + } + scanf("%d",&ch); + if(ch==1) + { + printf("编号:\n"); + scanf("%s",stu[i].num); + printf("\n姓名\n:"); + scanf("%s",stu[i].name); + printf(" \n电话:\n"); + scanf("%s",stu[i].tele); + printf(" \n地址:\n"); + scanf("%s",stu[i].add); + printf(" \nnemal:\n"); + scanf("%s",stu[i].emal); + printf(" 修改成功!\n"); + } +} +int tianjia(STUDENT stu[],int n) +{ + int i,j; + if(N<=n+1) + printf("储存已满"); + else + { + printf("请输入要插入的位置\n"); + scanf("%d",&i); + for(j=n-1;j>=i;j--) + { + strcpy(stu[j+1].name,stu[j].name); + strcpy(stu[j+1].tele,stu[j].tele); + strcpy(stu[j+1].add,stu[j].add); + strcpy(stu[j+1].emal,stu[j].emal); + } + printf("请输入要插入的信息:\n"); + printf("编号:\n"); + scanf("%s",stu[i].num); + printf("\n请输入姓名:\n"); + scanf("%s",stu[i].name); + printf(" \n请输入电话:\n"); + scanf("%s",stu[i].tele); + printf(" \n请输入地址:\n"); + scanf("%s",stu[i].add); + printf(" \n请输入emal:\n"); + scanf("%s",stu[i].emal); + printf("添加成功!\n"); + n++; + } + return n; +} +int tuichu() +{ + int n; + n=-1; + printf(" 谢谢使用 "); + return n; +}