为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

通讯录的制作

2017-09-19 20页 doc 229KB 22阅读

用户头像

is_219945

暂无简介

举报
通讯录的制作 数据结构课程设计报告 题目:通讯录的制作 目  录 中文摘要……………………………………………………………1 英文摘要……………………………………………………………2 1 绪 论……………………………………………………………1 2 系统分析………………………………………………………1 3 概要设计………………………………………………………2 3.1 主要数据结构…………………………………………2 3.2设计方法及原理…………………………………………2 3.3 流程图…………………………………………2 3.4设计结构体及基本数...
通讯录的制作
数据结构课程设计 题目:通讯录的制作 目  录 中文摘要……………………………………………………………1 英文摘要……………………………………………………………2 1 绪 论……………………………………………………………1 2 系统分析………………………………………………………1 3 概要设计………………………………………………………2 3.1 主要数据结构…………………………………………2 3.2设计及原理…………………………………………2 3.3 图…………………………………………2 3.4设计结构体及基本数据成员类型…………………3 4详细设计………………………………………………………5 5 运行与测试……………………………………………………11 6 总结与心得……………………………………………………14 附录……………………………………………………………15 参考文献………………………………………………………23 通讯录的制作 摘要 通讯录是现在社会中最常用到的东西,在信息社会,对通讯录的电子化已经是很平常的事了。本文主要叙述了一个制作通讯录的过程。系统主要是为了满足个人用户对联系人的管理和查询而设计。实现了用户对联系人信息的添加、查询、浏览、删除和对基本用户的管理,并且联系人的信息必须包括姓名、街道、城市、邮编、国家这些信息选项。 系统使用visual c++作为编程语言数据结构。系统设计突出人性化的特点。 关键词:通讯录;联系人;信息 Making mail list Abstract Mail list is something that society is the most commonly used to now, in the information society, the electronic mail list is already very common thing. This paper mainly describes the production of a mail list process. System is mainly to satisfy the query and management of individual users to contact and design. To achieve the user tocontact information to add, query, browse, delete and the basic user management,and contact information must include name, street, city, state, zip these information option. The system uses visual c++ as the programming language data structures. The system designed to highlight the characteristics of human nature. Keywords: mail list; contact; information 1 绪 论 1.1 前 言 通讯录的存在主要是主要是方便人们的生活。随着现代社会科技的发展你可以在个人电脑、掌上电脑、移动电话等任何联网设备上录入你的联系人的手机\电话号码、Email、QQ、MSN、通信地址等通讯录信息,或对以前的信息进行分组、管理和更新, 2 系统分析 1. 设计内容: 本系统应完成一下几方面的功能: ①输入信息(Enter()): 调用此用以输入数据到内存中,此过程包括建立相应的链表或相应的数组,便于读取。 ②显示信息(Display()):用以显示输入的数据,包括从内存中读出和从磁盘中读。 ③查找(Search()):以姓名作为关键字查找要找的信息。 ④删除信息(Delete()):用以删除选定的输入信息(姓名作为关键字)。 ⑤存盘(Save()):调用此函数将内存中的数据保存至磁盘中。 ⑥装入(Load()):调用此函数用以将之前保存在磁盘的内容读入到内存中或显示到屏幕上。 通讯录的基本活动包括:对一个人的采编、删除、查找和显示等等。由于上述四项基本活动都是通过人名(即关键字)进行的。 作为通讯录,就需要一个模块来完成对别人的登记和情况,本程序使用文件来完成上述操作。 2. 演示程序是以用户于计算机的对话方式执行,这需要一个模块来完成使用者与计算机语言是转化。 3. 程序执行时的命令: 本程序为了使用时的方便,采用菜单式的方式来完成程序的演示,几乎不用输入什么特殊的命令,只需按提示输入选者即可。当然也要注意输入时格式,否者可能会引起一些错误。 5.测试数据。要根据我们自己的需要进行测试,不能凭空的进行数据测试。 3 概要设计 3.1 主要数据结构 主要利用线性表的链式存储结构,来存储数据和信息。 3.2设计方法及原理   线性表的链式存储结构的特点是用一组任意的存储单元存储线性表的数据元素。 因此,为了表示每个数据元素与其后继元素之间的逻辑关系,对于数据元素来说,除了存储数据本身信息之外,还需要存储一个指示其后继的信息。 这两部分组成数据的存储映像,称为结点。 3.3 流程图 7exit() 退出 ch=getche() 3.4设计结构体及基本数据成员类型: (1) 结构体:(构造一个结构体来存储和使用数据) struct address{                        /*定义结构*/     char name[30];                  //姓名     char street[100];                //街道     char city[30];                  //城市     char state[30];                //国家     char zip[11];                  //邮政编码     struct address *next;                  /*后继指针*/     struct address *prior;                /*前导指针*/ }; struct address *start;                /*首结点*/ struct address *last;                  /*尾结点*/ struct address *find(char *);          /*声明查找函数*/ (2)包含被调用函数: 功能 void enter();          //输入信息              /*函数声明*/ void search();              //查找信息 void save();                //存盘 void load();                  //装入 void list();                    //显示信息 void mldelete(struct address **,struct address **);        //删除信息 void dls_store(struct address *i,struct address **start,                 struct address **last); void inputs(char *,char *,int); void display(struct address *); int menu_select(void); (3)实现主程序与各模块的调用关系: 主函数通过调用各个函数来连接各个函数,从而实现程序功能的实现。 int main(void) {   start = last = NULL;   for(;;)   {       switch(menu_select())       {           case 1:enter();             continue;           case 2:mldelete(&start,&last);             continue;           case 3:list();             continue;           case 4:search();             continue;           case 5:save();             continue;           case 6:load();             continue;           case 7:exit(0);       }     } } 4详细设计 (1)头函数 #include #include #include (2)被调用函数 1.添加学生信息:   void enter()                          /*输入函数,本函数循环输入资料,当输入姓名为空时退出*/ {     struct address *info;              /*定义当前结点*/     for(;;)     {         info=(struct address *)malloc(sizeof(struct address));  /*为当前结点分配空间*/         if(!info)         {             printf("\n Out of memory");             exit(0);                                              /*如果分配空间失败,退出程序*/         }         printf("输入空姓名结束:\n");         inputs("Enter name:",info->name,30);         if(!info->name[0])             break;                                /*如果输入姓名为空,结束循环*/         inputs("Enter street:",info->street,100);         inputs("Enter city:",info->city,30);         inputs("Enter state:",info->state,30);         inputs("Enter zip:",info->zip,11);       dls_store(info,&start,&last);          /*调用结点插入函数*/     } } 2删除联系人信息: void mldelete(struct address **start,struct address **last)        /*删除函数*/ {     struct address *info;     char s[80]; inputs("Enter name:",s,30);            /*输入欲删除结点的name域内容*/     info=find(s);                          /*查找该内容*/     if(info)                                /*如果找到*/     {         printf("Deleting......\n");         if(*start==info)                      /*如果该结点为首结点,把该结点的下驱作为新的首结点(入口)*/         {*start=info->next;           if(*start)         (*start)->prior=NULL;      /*如果新入口不为空,把入口的前驱置空*/ else *last=NULL;                    /*如果新入口为空,把尾结点置空,链表为空*/         }         else                                  /*如果欲删除的结点不是首结点*/         {info->prior->next=info->next;      /*令该结点的前驱的next指针指向该结点的后驱, *又令该结点的后驱的prior指点指向该结点的前驱*/             if(info!=*last)                    /*如果该结点是尾结点,则令该结点的前驱为尾结点*/                 info->next->prior=info->prior;             else             *last=info->prior;         }         free(info);                    /*释放该结点所占用的内存*/         printf("-Ok,deleted successfully!\n");     } } 3显示所有联系人; void list(void) {struct address *info;     info=start;     if(info==NULL)         printf("NO information!");     while(info)     {         display(info);         info=info->next;     }     printf("\n\n"); } void display(struct address *info)        /*输出传入结点函数*/ {     printf("%s\n",info->name);     printf("%s\n",info->street);     printf("%s\n",info->city);     printf("%s\n",info->state);     printf("%s\n",info->zip);     printf("\n\n"); } 4查找联系人信息; void search(void)                            /*查找函数*/ {     char name[40];     struct address *info;     printf("Enter name to find:");            /*输入欲查找的姓名*/     gets(name);     info=find(name);     if(!info)         printf("Not found\n");            /*如果没找到,显示Not found*/     else         display(info);                        /*如果找到,显示该结点资料*/ } 5装入 void load()                                      /*调用预存文件函数*/ {     register int t, size;     struct address *info,*temp=0;     char *p;     FILE *fp;                                    /*打开文件*/     if((fp=fopen("mlist","r"))==NULL)     {         printf("Cannot open file!\n");         exit(0);     }     printf("\n\nLoading...\n");                    /*调用文件*/     size=sizeof(struct address);          /*为结点分配内存*/     start==malloc(size);     if(!start)                                      /*如果读取失败,返回*/     {         printf("Out of memory!\n");         exit(0);     }     info=start;      p=(char*)info;     while((*p++=getc(fp))!=EOF)     {         for(t=0;tnext==malloc(size);         if(!info->next)         {             printf("Out of memory!\n");             return;         }         info->prior=temp;         temp=info;         info=info->next;         p=(char*)info;     }     temp->next=0;     last=temp;     start->prior=0;     fclose(fp);                                  /*关闭文件,释放内存*/     printf("-OK!\n"); } 6目录函数; int menu_select(void)                /*主目录*/ {     char s[80];     int c;     printf("…………欢迎使用通讯录系统…………\n");     printf("*****************************************\n");     printf("************** 1.输入信息 ***************\n");     printf("************** 2.删除信息 ***************\n");     printf("************** 3.显示信息 ***************\n");     printf("************** 4.查找    ***************\n");     printf("************** 5.存盘    ***************\n");     printf("************** 6.装入    ***************\n");     printf("************** 7.退出    ***************\n");     printf("*****************************************\n");     do{       printf("\nPlease enter your choice:\n");       gets(s);       c = atoi(s);     }while(c<0||c>7);                /*超出选项范围时,提示重新输入*/     return c;                          /*返回输入值*/ } 5 运行与测试 (1) 主界面 (2) 联系人信息的输入 (3) 联系人的信息的删除 (4) 联系人信息的显示 (5) 联系人的查找 (6) 联系人信息的装盘 6 总结与心得 附录 #include #include #include struct address{                        /*定义结构*/     char name[30];     char street[100];     char city[30];     char state[30];     char zip[11];     struct address *next;                  /*后继指针*/     struct address *prior;                /*前导指针*/ }; struct address *start;                /*首结点*/ struct address *last;                  /*尾结点*/ struct address *find(char *);          /*声明查找函数*/ void enter();                        /*函数声明*/ void search(); void save();                    void load(); void list(); void mldelete(struct address **,struct address **); void dls_store(struct address *i,struct address **start,                 struct address **last); void inputs(char *,char *,int); void display(struct address *); int menu_select(void); int main(void) {   start = last = NULL;   for(;;)   {       switch(menu_select())       {           case 1:enter();             continue;           case 2:mldelete(&start,&last);             continue;           case 3:list();             continue;           case 4:search();             continue;           case 5:save();             continue;           case 6:load();             continue;           case 7:exit(0);       }     } } int menu_select(void)                /*主目录*/ {     char s[80];     int c;     printf("………………欢迎使用通讯录系统………………\n");    printf("*****************************************\n");     printf("************** 1.输入信息 ***************\n");     printf("************** 2.删除信息 ***************\n");     printf("************** 3.显示信息 ***************\n");     printf("************** 4.查找    ***************\n");     printf("************** 5.存盘    ***************\n");     printf("************** 6.装入    ***************\n");     printf("************** 7.退出    ***************\n");     printf("*****************************************\n");     do{       printf("\nPlease enter your choice:\n");       gets(s);       c = atoi(s);     }while(c<0||c>7);                /*超出选项范围时,提示重新输入*/     return c;                          /*返回输入值*/ } void enter()                          /*输入函数,本函数循环输入资料,当输入姓名为空时退出*/ {     struct address *info;              /*定义当前结点*/     for(;;)     {         info=(struct address *)malloc(sizeof(struct address));  /*为当前结点分配空间*/         if(!info)         {             printf("\n Out of memory");             exit(0);                                              /*如果分配空间失败,退出程序*/         }         printf("输入空姓名结束:\n");         inputs("Enter name:",info->name,30);         if(!info->name[0])             break;                                /*如果输入姓名为空,结束循环*/         inputs("Enter street:",info->street,100);         inputs("Enter city:",info->city,30);         inputs("Enter state:",info->state,30);         inputs("Enter zip:",info->zip,11);       dls_store(info,&start,&last);          /*调用结点插入函数*/     } } void inputs(char *prompt,char *s,int count)        /*输入函数,有越界检测功能*/ {     char p[255];     do     {         printf(prompt);         fgets(p,254,stdin);         if(strlen(p)>count)             printf("\nToo Long\n");     }while(strlen(p)>count);     p[strlen(p)-1]=0;     strcpy(s,p); } void dls_store(                    /*数据插入函数,也是本例的关键函数*/           struct address *i,          /*接受传入的当前输入结点地址*/           struct address **start,    /*接受传入的首结点地址*/           struct address **last      /*接受传入的尾结点地址*/           ) {     struct address *old,*p;              /*定义临时指针*/     if(*last==NULL)                      /*如果尾结点为空,意味着当前链表为空*/     {         i->next=NULL;                      /*当前结点的后驱赋空*/         i->prior=NULL;                    /*当前结点的前驱赋空*/         *last=i;                          /*尾结点定义为当前结点*/         *start=i;                          /*首结点定义为当前结点*/         return;                            /*返回调用函数*/     }                                       /*如果链表不为空*/     p=*start;                            /*p取入口地址(也就是首结点地址)*/     old=NULL;                            /*old赋空*/     while(p)     {                                /*如果p不为空时,执行特循环体,查找比当前结点应该插入的位置*/         if(strcmp(p->name,i->name)<0)      /*如果当前结点的name域比p(首结点)大时(实现以name域升序排序)*/         {             old=p;                            /*old暂存p地址*/             p=p->next;                        /*p取下一结点*/         }         else                                /*如果当前输入数据中的name域比p小时,把数据插入结点p之前*/         {             if(p->prior)                      /*如果p的前驱不为空时*/             {                 p->prior->next=i;                /*令p的前驱的next域指向当前结点*/                 i->next=p;                      /*令当前结点的后继指向p*/                 i->prior=p->prior;              /*令当前结点的前驱指向p的前驱*/                 p->prior=i;                      /*令p的前驱为当前结点*/                 return;                          /*插入完成,返回调用函数*/             }             i->next=p;                        /*如果p的前驱为空时,把当前结点作为首结点,并令当前结点的后驱为p*/             i->prior=NULL;                    /*定义当前结点的前驱为空*/             p->prior=i;                      /*p的前驱为当前结点*/             *start=i;                        /*首结点(入口)为当前结点*/             return;                          /*插入完成,返回调用函数*/         }     }                                  /*循环体结束*/     old->next=i;                        /*如果在整个链表都找不到name域比当前数据的name域大的结点,                                         *把当前数据放在作为尾结点放在最后*/     i->next=NULL;                      /*令链表尾结点后驱批向当前结点,当前结点的后驱为空*/     i->prior=old;                      /*令当前结点的前驱为之前的最后结点*/     *last=i;                            /*尾结点取i地址*/ } void mldelete(struct address **start,struct address **last)        /*删除函数*/ {     struct address *info;     char s[80];     inputs("Enter name:",s,30);            /*输入欲删除结点的name域内容*/     info=find(s);                          /*查找该内容*/     if(info)                                /*如果找到*/     {         printf("Deleting......\n");         if(*start==info)                      /*如果该结点为首结点,把该结点的下驱作为新的首结点(入口)*/         {             *start=info->next;             if(*start)                 (*start)->prior=NULL;      /*如果新入口不为空,把入口的前驱置空*/             else *last=NULL;                    /*如果新入口为空,把尾结点置空,链表为空*/         }         else                                  /*如果欲删除的结点不是首结点*/         {             info->prior->next=info->next;      /*令该结点的前驱的next指针指向该结点的后驱,                                           *又令该结点的后驱的prior指点指向该结点的前驱*/             if(info!=*last)                    /*如果该结点是尾结点,则令该结点的前驱为尾结点*/                 info->next->prior=info->prior;             else             *last=info->prior;         }         free(info);                    /*释放该结点所占用的内存*/         printf("-Ok,deleted successfully!\n");     } } struct address *find(char *name)        /*查找函数,形参为欲查找结点的name域*/ {     struct address *info;     info=start;     while(info)     {         if(!strcmp(name,info->name))return info;         info=info->next;     }     printf("Name not found.\n");     return NULL; }                                           /*输出整个链表*/ void list(void) {     struct address *info;     info=start;     if(info==NULL)         printf("NO information!");     while(info)     {         display(info);         info=info->next;     }     printf("\n\n"); } void display(struct address *info)        /*输出传入结点函数*/ {     printf("%s\n",info->name);     printf("%s\n",info->street);     printf("%s\n",info->city);     printf("%s\n",info->state);     printf("%s\n",info->zip);     printf("\n\n"); } void search(void)                            /*查找函数*/ {     char name[40];     struct address *info;     printf("Enter name to find:");            /*输入欲查找的姓名*/     gets(name);     info=find(name);     if(!info)         printf("Not found\n");            /*如果没找到,显示Not found*/     else         display(info);                        /*如果找到,显示该结点资料*/ } void save(void)                            /*保存函数*/ {     struct address *info;     FILE *fp;     fp=fopen("mlist","wb");                  /*生成文件*/     if(!fp)     {         printf("Cannot open file.\n");         return;     }     printf("\nSaveing ……\n");     info=start;     while(info)                                /*把链表写入文件*/     {         fwrite(info,sizeof(struct address),1,fp);         info=info->next;     }     printf("-ok!\n");     fclose(fp);/*链表全部写入文件后,关闭文件*/     } void load()                                      /*调用预存文件函数*/ {     register int t, size;     struct address *info,*temp=0;     char *p;     FILE *fp;                                    /*打开文件*/     if((fp=fopen("mlist","r"))==NULL)     {         printf("Cannot open file!\n");         exit(0);     }     printf("\n\nLoading...\n");                    /*调用文件*/     size=sizeof(struct address);          /*为结点分配内存*/     start==malloc(size);     if(!start)                                      /*如果读取失败,返回*/     {         printf("Out of memory!\n");         exit(0);     }     info=start;      p=(char*)info;     while((*p++=getc(fp))!=EOF)     {         for(t=0;tnext==malloc(size);         if(!info->next)         {             printf("Out of memory!\n");             return;         }         info->prior=temp;         temp=info;         info=info->next;         p=(char*)info;     }     temp->next=0;     last=temp;     start->prior=0;     fclose(fp);                                  /*关闭文件,释放内存*/     printf("-OK!\n"); } 参考文献 文档已经阅读完毕,请返回上一页!
/
本文档为【通讯录的制作】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索