《程序设计实践》课程报告-.doc_第1页
《程序设计实践》课程报告-.doc_第2页
《程序设计实践》课程报告-.doc_第3页
《程序设计实践》课程报告-.doc_第4页
《程序设计实践》课程报告-.doc_第5页
已阅读5页,还剩28页未读 继续免费阅读

下载本文档

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

文档简介

课 程 名 称: 程序设计实践 专 业 班 级 : 学 生 姓 名 : 学 号 : 任 课 教 师 : 学 期 : 课程报告任务书题 目通讯录管理系统主要内容开发一个模拟手机通讯录管理软件,联系人信息主要包括:姓名、性别、电话号码、总通信次数、qq号码、微信号码、电子邮件、生日等信息。(也可以根据自己情况进行扩充),也可以进一步地将联系人划分为所属组名称:比如同事,同学,朋友,亲人等)。通信次数(包括语音通话、短信、邮件等的通信的计次总次数),使之有基本功能:(1)联系人信息录入功能(数据信息用文件保存)v(2)联系人信息的浏览功能(浏览的方式可以自行决定)(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式): l 按姓名查询 按号码查询 按照姓名排序 按年龄排序等或通信次排序 (4)联系人信息的删除与修改扩展功能:比如(1)简单的权限处理 (2)报表打印功能(3)联系人分组的功能,可以进一步扩充,比如新建分组、修改分组名称,批量移动信息人,如qq分组功能。(4)查询:比如按拼音首字符查询或者按全拼查询 (5)按照部分号码查询 (6)备份数据功能等;(7)根据联系人信息中的总通信次数可以进行排序,总之,可以根据自己需求进行分析功能。任务要求一、提交材料应包括:(1)系统源代码 (2)课程报告二、整个设计过程具体要求(1)需求分析 要求学生对案例系统进行分析,设计出需要完成的功能,完善各个模块的调用关系;(2)设计过程 要求学生进一步明确各模块调用关系,进一步完善模块函数细节(函数名、参数、返回值等)(3)实现过程 要求学生养成良好的编码习惯、完成各个模块并进行测试,最终完成系统整体测试;(4)总结阶段 按照要求完成系统设计和实现报告,并进行总结、答辩。成绩评定报告撰写情况(30分)系统完成情况(30分)答辩情况(40分)总分内容20分规范程度5分程序测试5分基本功能20分扩展功能10分自述情况10分答辩情况30分成绩评定教师: 1 需求分析1.1.开发一个一个手机通讯录,用于记录联系人的姓名,年龄,性别,手机号码,qq号码,家庭住址,以及电子邮件。1.2.满足用户对通讯录的基本操作:新建,删除,修改,排序,查找,浏览,以及文件的读与写,扫描已有文件中的联系人资料。新建:用户可以添加多个联系人。并进行按照名字排序。删除:满足用户按照名字对联系人进行删除操作。修改:满足用户对联系人的信息进行修改。排序:实现联系人按照名字和号码进行排序。查找:满足用户对联系人进行查找,对名字、号码和qq号码进行查找处理。浏览:输出所有人的信息。文件的读与写:对联系人的保存与读。2 概要设计(小三黑体)2.1模块概要2.1.1定义变量结构体struct friends_list /储存联系人信息 char name20; /姓名 char age5; /年龄 char sex3; /性别 char phonenumber15; /电话号码 char qqnumber12; /qq号码 char address80; /地址 char num500; /编号 char mail40; /电子邮箱 struct friends_list *next;2.1.2 自定义函数struct friends_list *load_friend(struct friends_list *head);/从文件中读取联系人void save_friend(struct friends_list *head);/保存联系人struct friends_list *create_lianxi_doc(struct friends_list *head); /新建联系人struct friends_list *delete(struct friends_list *head,char *name); /删除联系人struct friends_list*xiugai(struct friends_list*head,char *name); /修改联系人struct friends_list *sort_friend(struct friends_list *head,char *name);/排序void print_friends_doc(struct friends_list *head); /查看所有联系人void search_friend1(struct friends_list *head,char *name);/按姓名对联系人进行查找void search_friend2(struct friends_list *head,char *phonenum);/按电话号码对联系人进行查找void search_friend3(struct friends_list *head,char *qqnumber); /按qq号码对联系人进行查找struct friends_list *scanf_friend();/扫描文件2.1.3 流程图与模块图开始输入选项进行操作新建联系人导入已存联系人信息是否保存联系人信息修改信息删除联系人浏览联系人排序查找联系人按姓名查找按电话号码查找按qq号码查找通讯录管理系统新建读取删除修改浏览保存查找排序输入联系人信息文件中读取联系人输入需删除的联系人姓名删除联系人所修改联系人姓名修改内容已建立的联系人信息按姓名查找按电话查找按qq号码查找按姓名排序 图1.12.1.4 自定义模块2.1.4.1 新建联系人 此模块为联系人的新建,用户在提醒语句的提示下依次输入新建联系人的信息,并且在用户输入最后一条信息后回车结束新建,系统自动返回主菜单参数为head,返回值为head。2.1.4.2 读取文件中已有联系人 此模块主要用于用户浏览已有联系人的信息,参数为head,返回值为head。2.1.4.3 删除联系人 用户通过输入所要删除的联系人姓名进行删除操作,执行此操作时,用户将删除所输入联系人的所有信息,参数为head、name,返回值为head。2.1.4.4 修改联系人 调用此模块时,用户将首先输入想要修改的联系人姓名,之后将进一步选择所要修改的信息选项,当用户将所有要修改的信息修改完成后可选择0退出修改操作并返回主菜单;参数为head、name,返回值为head;2.1.4.5 浏览联系人 对于已保存的联系人信息(或文件中已存在的联系人信息)可选择此操作进行遍历操作,参数为head,无返回值;2.1.4.6 保存 用户在完成联系人的新建后,可选择此操作进行保存处理,保存的联系人信息将写入文件中(若文件不为空择将在文件中续写),参数为head,无返回值;2.1.4.7 联系人排序 此操作可将联系人按照姓名进行重新排序,参数为head、name,返回值为head;2.1.4.8 查找联系人 在选择此操作的时候,用户将进入查找方式的选择界面,通过输入序号进行选择查找方式,此操作共有三种搜索方式供用户选择1姓名2电话3qq号码,参数为head,无返回值。3 详细设计# include# include# includestruct friends_list/储存联系人信息 char name20; /姓名 char age5; /年龄 char sex3; /性别 char phonenumber15;/电话号码 char qqnumber12;/qq号码 char address80;/地址 char num500;/编号 char mail40;/电子邮箱 struct friends_list *next;int count=0;/全局变量 储存联系人个数int system(const char *string);struct friends_list *load_friend(struct friends_list *head);/从文件中读取联系人void save_friend(struct friends_list *head);/保存联系人struct friends_list *create_lianxi_doc(struct friends_list *head); /新建联系人struct friends_list *delete(struct friends_list *head,char *name); /删除联系人struct friends_list*xiugai(struct friends_list*head,char *name); /修改联系人struct friends_list *sort_friend(struct friends_list *head,char *name);/排序void print_friends_doc(struct friends_list *head); /查看所有联系人void search_friend1(struct friends_list *head,char *name);/按姓名对联系人进行查找void search_friend2(struct friends_list *head,char *phonenum);/按电话号码对联系人进行查找void search_friend3(struct friends_list *head,char *qqnumber); /按qq号码对联系人进行查找struct friends_list *scanf_friend();=主函数=int main(void)/主函数 struct friends_list *head; char choice; int choices; char name20; /*姓名*/ char phonenum15; char qqnumber13; head=null;head=scanf_friend(); do printf(ttt欢迎进入通讯录n); printf(tttt1.新建n); printf(tttt2.读取n); printf(tttt3.删除n); printf(tttt4.修改n); printf(tttt5.浏览n); printf(tttt6.保存n); printf(tttt7.排序n); printf(tttt8.查找n); printf(tttt0.退出n); printf(tttn); scanf(%c,&choice); getchar(); while(choice8)printf(n对不起,您输入有误!请重新输入!n);scanf(%c,&choice);getchar(); switch(choice) case 1: head=create_lianxi_doc(head);break; case 2: head=load_friend(head); break; case 3: printf(请输入您要删除的联系人姓名:n); gets(name); head=delete(head,name); break; case 4: printf(请您输入要修改的联系人的名字:); gets(name); while(strlen(name)=0) gets(name); head=xiugai(head,name); break; case 5: print_friends_doc(head); break; case 6: save_friend(head); break; case 7: head=sort_friend(head,name); break; case 8: printf(请选择您的查询方式:n); printf(1.按姓名对联系人进行查找n); printf(2.按电话号码对联系人进行查找n); printf(3.按qq号码对联系人进行查找n); scanf(%d,&choices); while(choices3)if(choices=n)printf(对不起,您输入有误!n);scanf(%d,&choices); switch(choices) case 1: printf(请输入您要查询的联系人姓名:); getchar(); gets(name); search_friend1(head,name); break; case 2: printf(请输入您要查询的联系人电话号码:); getchar(); gets(phonenum); search_friend2(head,phonenum); break; case 3: printf(请输入您要查询的联系人qq号码:); getchar(); gets(qqnumber); search_friend3(head,qqnumber); break; break; case 0: break; while(choice!=0); return 0; 新建联系人 struct friends_list *create_lianxi_doc(struct friends_list *head) struct friends_list *p,*tail; char name20; /姓名 char age5; /年龄 char sex5; /性别 char phonenumber15; /电话 char qqnumber12; /qq号码 char address80; /地址 char mail40; /电子邮箱 int flag=0; if(count=100) /判断通讯录是否已已满 printf(通讯录已满!n); return 0; if(head!=null) /判断链表是否为空 for(p=head;p;p=p-next) tail=p; p=null; p=(struct friends_list*)malloc(sizeof(struct friends_list); /申请变量空间 printf(请输入新的联系人姓名:); gets(name); if(strlen(name)=0) printf(对不起,联系人姓名不能为空!n);gets(name); strcpy(p-name,name); printf(请输入新建联系人年龄:); gets(age); strcpy(p-age,age); printf(请输入新建联系人性别:); gets(sex); strcpy(p-sex,sex); printf(请输入新建联系人号码:); gets(phonenumber); strcpy(p-phonenumber,phonenumber); printf(请输入新建联系人qq号码:); gets(qqnumber); strcpy(p-qqnumber,qqnumber); printf(请输入新建联系人的住址:); gets(address); strcpy(p-address,address); printf(请输入新建联系人电子邮箱:); gets(mail); strcpy(p-mail,mail); p-next=null;if(head=null)head=p;elsetail-next=p;count+;printf(新联系人创建成功!); return head; 读取文件中已存联系人struct friends_list *load_friend(struct friends_list *head)file *fp;char name20; /*姓名*/ char age5; /*年龄*/ char sex3; /*性别*/ char phonenumber15; char qqnumber12; char address80; char mail40;if(fp=fopen(通讯录.txt,r)=null)printf(cannot open file strike any key exit!n);exit(0);while(!feof(fp)fscanf(fp,%sn,name);printf(姓名:);printf(%-10sn,name);fscanf(fp,%sn,age);printf(年龄:);printf(%-10sn,age);fscanf(fp,%sn,sex);printf(性别:);printf(%-10sn,sex);fscanf(fp,%sn,phonenumber);printf(电话:);printf(%-10sn,phonenumber);fscanf(fp,%sn,qqnumber);printf(qq号码:);printf(%-10sn,qqnumber);fscanf(fp,%sn,address);printf(住址:);printf(%-10sn,address);fscanf(fp,%sn,mail);printf(电子邮箱:);printf(%-10sn,mail);if(fclose(fp)printf(cannot close this file!n);exit(0);return head;printf(n读入文件成功!n);删除联系人struct friends_list*delete(struct friends_list*head,char *name) struct friends_list *ptr1,*ptr2; while(head!=null&strcmp(head-name,name)=0) ptr2=head; head=head-next; free(ptr2); if(head=null) return null; ptr1=head; ptr2=head-next; /从头开始搜索符合要求的结点 while(ptr2!=null) if(strcmp(ptr2-name,name)=0) ptr1-next=ptr2-next; free(ptr2); /释放空间 else ptr1=ptr2; ptr2=ptr1-next; printf(删除成功!); return head;修改联系人信息struct friends_list *xiugai(struct friends_list *head,char *name) struct friends_list*p; char age5; /年龄 char sex3; /性别 char phonenumber15; /电话号码 char qqnumber12; /qq号码 char address80; /地址 char mail40; /电子邮箱 int choice; int flag=0; if(count=0) /判断通讯录是否为空 printf(通讯录无记录!无法进行操作!); return head; for(p=head;p;p=p-next) if(strcmp(name,p-name)=0) do printf(请选择您要修改的内容:n); printf(1.姓名n); printf(2.年龄n); printf(3.性别n); printf(4.电话n); printf(5.qq号码n); printf(6.家庭住址n); printf(7.电子邮箱n); printf(0.退出n); scanf(%d,&choice); getchar(); switch(choice) /选择修改内容 case 1: printf(请输入姓名:);gets(name);strcpy(p-name,name); break;case 2: printf(请输入年龄:); gets(age); strcpy(p-age,age); break; case 3: printf(请输入性别:); gets(sex); strcpy(p-sex,sex); break;case 4: printf(请输入电话:); gets(phonenumber); strcpy(p-phonenumber,phonenumber); break;case 5: printf(请输入qq号码:); gets(qqnumber); strcpy(p-qqnumber,qqnumber); break; case 6: printf(请输入家庭住址:); gets(address);strcpy(p-address,address); break; case 7: printf(请输入电子邮箱:); gets(mail); strcpy(p-mail,mail); break; case 0: break; while(choice!=0); flag=1; if(flag=1) /修改的判断 printf(修改成功!n); else printf(修改失败!); return head; 浏览联系人信息void print_friends_doc(struct friends_list*head) struct friends_list*ptr; if(head=null) /判断链表是否为空 printf(n无记录!n); return; for(ptr=head;ptr;ptr=ptr-next) /从第一个联系人开始循环输出显示所有联系人信息 printf(n联系人信息:n); printf(姓名:); printf(%sn,ptr-name); printf(年龄:); printf(%sn,ptr-age); printf(性别:); printf(%sn,ptr-sex); printf(电话:); printf(%sn,ptr-phonenumber); printf(qq号码:); printf(%sn,ptr-qqnumber); printf(住址:); printf(%sn,ptr-address); printf(电子邮箱:); printf(%sn,ptr-mail); 保存void save_friend(struct friends_list *head)file *fp;struct friends_list *p;int flag=0;if(fp=fopen(通讯录.txt,w)=null)printf(cannot open file strike any key exit!n);exit(0);for(p=head;p;p=p-next)fprintf(fp,%s ,p-name);if(strlen(p-age)=0)fprintf(fp,%c ,#);elsefprintf(fp,n%sn,p-age);if(strlen(p-sex)=0)fprintf(fp,%c ,#);elsefprintf(fp,%s ,p-sex);if(strlen(p-phonenumber)=0)fprintf(fp,%c ,#);elsefprintf(fp,%s ,p-phonenumber);if(strlen(p-qqnumber)=0)fprintf(fp,%c ,#);elsefprintf(fp,%sn,p-qqnumber);if(strlen(p-address)=0)fprintf(fp,%c ,#);elsefprintf(fp,%sn,p-address);if(strlen(p-mail)=0)fprintf(fp,%c ,#);elsefprintf(fp,%sn,p-mail);if(fclose(fp)printf(文件关闭错误!n);flag=1;exit(0);if(flag=0)printf(n所有联系人已被成功保存!n);排序struct friends_list *sort_friend(struct friends_list *head,char *name) char age5; /*年龄*/ char sex3; /*性别*/ char phonenumber15; char qqnumber12; char address80; char mail40; struct friends_list*p1,*p2,*index; if(count=0)printf(n此通讯录为空!n);return head; for(p1=head;p1-next!=null;p1=p1-next)index=p1;for(p2=p1-next;p2;p2=p2-next)if(strcmp(p2-name),(p1-name)name);strcpy(p1-name,index-name);strcpy(index-name,name);strcpy(age,p1-age);strcpy(p1-age,index-age);strcpy(index-age,age);strcpy(sex,p1-sex);strcpy(p1-sex,index-sex);strcpy(index-sex,sex);strcpy(phonenumber,p1-phonenumber);strcpy(p1-phonenumber,index-phonenumber);strcpy(index-phonenumber,phonenumber);strcpy(qqnumber,p1-qqnumber);strcpy(p1-qqnumber,index-qqnumber);strcpy(index-qqnumber,qqnumber);strcpy(address,p1-address);strcpy(p1-address,index-address);strcpy(index-address,address);strcpy(mail,p1-mail);strcpy(p1-mail,index-mail);strcpy(index-mail,mail);printf(n排序已完成!n);return head;按姓名对联系人进行查找void search_friend1(struct friends_list *head,char *name)struct friends_list *p;int flag=0;if(count=0)printf(n此通讯录为空!n);return;for(p=head;p;p=p-next)if(strcmp(name,p-name)=0)printf(姓名:%sn,p-name);printf(年龄:%sn,p-age);printf(性别:%sn,p-sex);printf(电话号码:%sn,p-phonenumber);printf(qq号码:%sn,p-qqnumber);printf(住址:%sn,p-address);printf(电子邮箱:%sn,p-mail);flag=1;break;if(flag=0) printf(n输入错误或通讯录中没有此人!n);按电话号码对联系人进行查找void search_friend2(struct friends_list *head,char *phonenumber)struct friends_list *p;int flag=0;if(count=0)printf(n此通讯录为空!n);return;for(p=head;p;p=p-next)if(strcmp(phonenumber,p-phonenumber)=0)printf(姓名:%sn,p-name);printf(年龄:%sn,p-age);printf(性别:%sn,p-sex);printf(电话号码:%sn,p-phonenumber);printf(qq号码:%sn,p-qqnumber);printf(住址:%sn,p-address);printf(电子邮箱:%sn,p-mail);flag=1;break;if(flag=0) printf(n输入错误或通讯录中没有此人!n);按qq号码对联系人进行查找void search_friend3(struct friends_list *head,char *qqnumber)struct friends_list *p;int flag=0;if(count=0)printf(n此通讯录为空!n);return;for(p=head;p;p=p-next)if(strcmp(qqnumber,p-qqnumber)=0)printf(姓名:%sn,p-name);printf(年龄:%sn,p-age);printf(性别:%sn,p-sex);printf(电话号码:%sn,p-phonenumber);printf(qq号码:%sn,p-qqnumber);printf(住址:%sn,p-address);printf(电子邮箱:%sn,p-mail);flag=1;break;if(flag=0) printf(n输入错误或通讯录中没有此人!n);文件的扫描 struct friends_list *scanf_friend()file *fp;struct friends_list *p,*tail,*head;head=null;if(fp=fopen(通讯录.txt,r)=null)printf(cannot open file strike any key exit!n);exit(0);fseek(fp,0,2);if(ftell(fp)=0) printf(ttn);printf(tt通讯录为空!n);printf(ttn);printf(ttt 请新建联系人信息!n);head=null;elserewind(fp);while(!feof(fp)p=null;p=(struct friends_list*)malloc(sizeof(struct friends_list);fscanf(fp,%sn,p-name);fscanf(fp,%sn,p-age);fscanf(fp,%sn,p-sex);fscanf(fp,%sn,p-phonenumber);fscanf(fp,%sn,p-qqnumber);fscanf(fp,%sn,p-address);fscanf(fp,%sn,p-mail);p-next=null;if(head=null)head=p;tail=p;count+;elsetail-next=p;tail=tail-next;count+;if(fclose(fp)printf(文件关闭错误!n);exit(0);return head;4 调试分析1.在输入联系人信息时未按提示顺序在不同信息输入完成后依次提示输入(如:“联系人姓名:年龄:”),问题在于没有getchar()吸收回车符;2.浏览时所有联系人信息连续输出显示两遍,原因是文件扫描是没有加n;3.运行程序是,进行读取文件中已存联系人时只是单纯

温馨提示

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

评论

0/150

提交评论