C语言课程设计 通讯录管理系统_第1页
C语言课程设计 通讯录管理系统_第2页
C语言课程设计 通讯录管理系统_第3页
C语言课程设计 通讯录管理系统_第4页
C语言课程设计 通讯录管理系统_第5页
已阅读5页,还剩73页未读 继续免费阅读

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

集团文件发布号:(9816-UATWW-MWUB-WUNN-INNUL-DQQTY-本科生课程论文封面类别:评语对课程论文的评语:思路根据题目的要求,程序应该采用结构体数组和文件系统实现。应该有动态的存储空间和文件输入、输出等操作功能;在程序中应该包括添加、显示、删除、查询数据结构设计是全局变量MAXmeaddrphnumemail,只提供输入,功能处理和输出部分的函数调用ain********主函数*****************/*变量保存选择菜单数子***************/printfntn;printfnnt***********WELCOMETOUSE!***************\n");printfnt*******************************************\n");printfnntt****Pleasemakeachoicebelow*****\n");printfntapieceofmeg");printfntallthemeg");printfntapieceofmeg");printfntapieceofmeg");printfntapieceofmeg");printfntandQuit");printfntanaddressbook");printfnnn;printft****InputYourChoice:****************\n");switchn***输入n的在1-6之间执行switch***/kcaseList/*显示模块*/kcaseDelete删除模块*/kd/*查询模块:分为名字查询(0)和电话号码查询(1)*/kr/*修改模块:分为修改名字(0)和修改电话号码(1)*/kxitkeat*/default***输入的n不在1-6之间执行default***/printfnt*****************************************\n");printfntThenumshouldbe1-6!!!printfnt*****************************************\n");k}}模块设计mail以采用字符型数组;可以采用结构体的形式,把各信息作为结构的成找、和删除的功能,所以整个通讯录采用链表比较变量作为链表中的接点是最合适的。结构体变量可指针类型的成员来存放下一个结点的地址。结构体enuml*****定义头指针和尾指针*************/psp*p1,*p2,*p3,*p4,*p5;echcharstr;ILEfp***********定义文件指针***********************/voidcreat/*将文件的信息读入结构体数组在转存入链表中*/fpfopenr************打开文件**********************/k=i-1;kfpksizeofstructpersons***读取一个人的信息***************/readpersonsisizeofstructpersonsfpocsizeofp*****装存入链表中***********/rsonsinamepersonsiaddrersonsiphnumilpersonsiemailifheadNULL用尾插法将其插入链表中**********/}}voidAdd()/*******向通讯录中添加(或输入)一个人的信息*********/printfnnt*******Pleaseinputthesb'smessage:**********");printfnnttname");eprintfnnttAddr");rprintfnnttphnum");mprintfnnttemai");lL讯录为空则添加在头指针之后相当于输入信息*********/t=s;}}定义了头指针,则所有的信息就很容易的找到,指针会一环ist********显示所有的信息*******************/pheadp****/whilep!=NULL)/****************通讯录不为空******************/printftaddrs",p0->addr);printftphnums",p0->phnum);printftemails\n",p0->email);ppnext/**************p0向后移一个位置*****************/}}于是删除链表中的一个结点。在删除后又要保证链表不间断动地把手牵起来,保证lete***定义一个删除的函数***************/dprintfnt******Pleaseinputaname:*************\n");名*/printfnttname");while(strcmp(name0,p1->name)!=0)&&(p1!=NULL))可能性*/ppnext;}******指针向后移一个位置****************/ifstrcmpnamepname除的位置*******/tnextpnextprintfnt***********Deletesuccessn);}printfnt**********Deletefail!******************\n");置*/}为姓名查询和电话号码查询voidFind***********定义一个查询的函数**************/rphnumnameprintf"\n\t*******Searchbynameorphpnumnamen0)\phnum(n=1)*********\n");printf**Inputthenumberof'n':*************\n");**********选择查询方式******************/ifn***********姓名查询***************/dscanfsname*********输入姓名***************/while(strcmp(name1,p3->name)!=0)&&(p3!=NULL))可能性*/ppnext;ifpnameNULL没有找到**************/dthemessageseifstrcmpnamepname息并输出******/nprintfntname%s",p3->name);printftaddresss",p3->addr);printftemail%s",p3->email);printftphnum%s",p3->phnum);}}******电话号码查询***************/d*******输入电话号码***************/while(strcmp(phnum1,p3->phnum)!=0)&&(p3!=NULL))可能性*/ppnext;ifpphnumNULL***没有找到**************/dthemessageseifstrcmpphnumpphnum息并输出******/printfntname%s",p3->name);修改姓名和修改电话号码,修改模块的设计思路ter******定义一个修改的函数*****************/输入新的电话号 printf("\n\n\t****Whichmessagedoyouwantto输入新的电话号 alternamem\phnum(m=1)*********\n");printf*******Inputthenumberof'm':******************\n");**********选择修改内容******************/************修改姓名*********************/*****输入要修改的姓名***************/dwhile(strcmp(name2,p4->name)!=0)&&(p4!=NULL))可能性*/ppnext;ifpNULLprintfntCannotfindthemame********\n");}seifstrcmpnamepname到要修改的姓名********/nessagenprintfnnnttname:");canfsname/**********输入新的信息**********/strcpypnamename*****新的姓名修改成功*******/printfnnt**********Alteredsuccess!************\n");}}******修改电话号码***************/***输入要修改的电话号码***************/dwhile(strcmp(phnum2,p4->phnum)!=0)&&(p4!=NULL))可能性*/ppnext;hephnumnseifstrcmpphnumpphnum修改的电话号码*****/ssagenprintfnnnttphnum:");*输入新的信息**********/hnum电话号码修改成功*******/printfnnt**********Alteredsuccess!************\n");}}}ave***定义一个保存信息的函数************/enwforpheadjpNULLj+,p5=p5->next)体数组在出入链表中*/sonsjaddrpaddronsjphnumpphnumonsjemailpemailwritepersonsjsizeofstructpersonsfp}}include<>include<>include<>#defineMAX100{luctplpsp*p1,*p2,*p3,*p4,*p5;echcharstr;ILEfpcreatpenrk=i-1;kfpksizeofstructpersonsreadpersonsisizeofstructpersonsfpocsizeofprsonsinamepersonsiaddrersonsiphnumilpersonsiemailLprintfnnttAddr");}}}}}dprintfnnt******Pleaseinputthesb'smessage:**********");printfnnttname");erprintfnnttphnum");mprintfnnttemai");lL}}ist{dwhilep0!=NULL)printftaddrs",p0->addr);printftphnums",p0->phnum);printftemails\n",p0->email);ppnext;}}lete{dprintfnt*******Pleaseinputaname:**************\n");printfnttname");while(strcmp(name0,p1->name)!=0)&&(p1!=NULL))ppnext;}ametnextpnextprintfnt***********Deletesuccess!******************\n");}elseprintfnt***Deletefail!******************\n");}nd{rphnumnameprintf"\n\t*******Searchbynameorphpnumnamen0)\phnum(n=1)*********\n");printf**Inputthenumberof'n':*************\n");dwhile(strcmp(name1,p3->name)!=0)&&(p3!=NULL))ppnext;{printfnt***********Cannotfindthemessage!**********");}seifstrcmpnamepname{printfnt*****Foundthemessage:**********************\n");printfntname%s",p3->name);printftaddresss",p3->addr);printftemail%s",p3->email);printftphnum%s",p3->phnum);}}dwhile(strcmp(phnum1,p3->phnum)!=0)&&(p3!=NULL))ppnext;hemessageseifstrcmpphnumpphnumgeprintfntname%s",p3->name);printftaddresss",p3->addr);printftemail%s",p3->email);printftphnums",p3->phnum);}}}ter{mnameprintf("\n\n\t****Whichmessagedoyouwanttoalternamemphnumm1)*********\n");printf******Inputthenumberof'm':***********************\n");dwhile(strcmp(name2,p4->name)!=0)&&(p4!=NULL))ppnext;ifpNULLprintfntCannotfindthemame********\n");}seifstrcmpnamepnameewnessagenprintfnnnttname:");ameprintfnnt**********Alteredsuccess!************\n");}}numpheadwhile(strcmp(phnum2,p4->phnum)!=0)&&(p4!=NULL))ppnext;hephnumnseifstrcmpphnumpphnumnessagenprintfnnnttphnum:");hnumprintfnnt**********Alteredsuccess!************\n");}}}aveenwforpheadjpNULLj+,p5=p5->next)sonsjaddrpaddronsjphnumpphnumonsjemailpemailwritepersonsjsizeofstructpersonsfp}}ainprintfntn;printfnnt***********WELCOMETOUSE!***************\n");printfnt*******************************************\n");printfnntt****Pleasemakeachoicebelow*****\n");printfntapieceofmeg");prin

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论