ImageVerifierCode 换一换
格式:DOCX , 页数:30 ,大小:21KB ,
资源ID:29450922      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/29450922.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C语言课程设计报告212899.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C语言课程设计报告212899.docx

1、C语言课程设计报告212899C语言课程设计报告 题目: 学 院 专 业 年级班别 学 号 学生姓名 指导教师 成 绩 2009年12月 1. 课程设计题目,内容,要求设计一个学生通讯录管理系统,在动态链表程序的基础上,设计要求如下(必须使用结构体和链表等数据结构)1建立文件 存储文件使用指定文件名或默认文件名; 可以不保存输入记录,但需要确认是否保存输入记录 如果已有文件,只能在其后追加; 新增记录可以不存入原文件中,以可以用原来的文件覆盖内存的内容;可以将多个个文件记录合并到一个文件中;2文件的存取和显示 可以单独存取文件; 可以随时显示内存中记录的全部内容; 可以直接存取默认文件或指定文

2、件;3删除记录 可以按“姓名”或“电话”方式删除记录并更新内存链表内容; 能给出被删除的信息,输出没有找到的信息; 如果已经是空表,上出时应给出信息并返回主菜单; 如果没有要删除的信息,输出没有找到的信息;删除操作仅限于内存,只有执行记录时,才能覆盖原记录;4查询记录 可以按“姓名”或“电话”或“宿舍”方式查询记录 能给出查询记录的信息;如果查询的信息不存在,输出没有找到的信息;5 整体功能 a可以随时检索、删除、或增加新记录,保存或取消新的记录 b使姓名可由16位字符和数字的混合编码组成 c使电话号码可由18位字符和数字组成d将输出信息加上输出信息信息栏,例如 姓名 电话 性别 年龄 生日

3、宿舍 李四 1234 男 21 7月1日 东二333 e使用菜单实现功能的正确的选择 f 所有节点信息都是动态生成。6测试程序 应列出测试大纲对程序进行测试; 应保证测试用例测试到程序的各种边缘情况二总体设计系统包括的函数有Main.c:整个系统的主函数Menu.c:系统的主界面Creat.c:创建链表Add.c:追加记录Del.c:删除记录Modify.c:修改记录Read.c:从外部文件读取记录Save.c:保存记录到外部文件Search.c:查找记录Skim.c:浏览记录Headyy.h:头文件系统功能模块结构图:MainmenuCreat.c Add.c Del.c Modify.c

4、Read.c Save.c Search.c Skim.c三详细设计 程序清单:headyy.h#ifndef NULL #define NULL 0 #endif #include#include#include#include#include#define LEN sizeof(struct addbok)#define PR printf(%-12s%-12s%-12s%-10s%-10s%-10s%-12sn,Num.,Name,Tel.,Sex,Age,Birtday,Dormitory);struct addbok /*声明结构体类型*/ long num; char nam16;

5、 /*储存编号*/ char tel18; /*储存电话*/ char sex4; /*学生性别*/ int age; /*学生年龄*/ char bir10; /*学生生日*/ char dor13; /*学生宿舍*/ struct addbok * next; ;void print(struct addbok *);具体实现:创建了结构体变量addbokmain.c#include extern int n=0;void main() int c,color,i=0; struct addbok *head; head=NULL; for(color=0;color6;color+) t

6、extcolor(color); /*字体颜色*/ textbackground(color+2); /*屏幕颜色*/ clrscr(); printf(nnnnnnnnnntttWelcome to Students Address System); printf(nn); printf(ttttttDesign by YangYing); sleep(1); /*延时1秒*/ clrscr(); while(i=0) system(cls); printf(=Students Address System=); printf(* * * * * * * * * * * * * * * *

7、* * * * * * * * * * * * * * * * * * * * * * * *n); printf(* NO.: Name:YangYing Class:Science Of Computer Class1 *n); printf(* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *n); printf(=); c=meun(); switch(c) case 1:head=creat();break; /*指向creat.c*/ case 2:head=add(head)

8、;break; /*指向add.c*/ case 3:skim(head);break; /*指向skim.c*/ case 4:head=modify(head);break; /*指向modify.c*/ case 5:search(head);break; /*指向search.c*/ case 6:head=del(head);break; /*指向del.c*/ case 7:head=read();break; /*指向read.c*/ case 8:save(head);break; /*指向save.c*/ case 0: exit(0); /*退出系统*/ default:

9、printf(Discorrect!Please enter again.nn); getch(); 具体实现:设置了开始的欢迎词,并且对照参考书设置了背景色和字体颜色,每种颜色延时1秒,在此函数中输入了自己的学号班级姓名,并且用switch语句实验了选择功能操作的函数指向。menu.c#include extern int n;int meun(void) int i; printf(nn); printf( #menu#n); printf( *n); printf( | 1:Creat 2:Add item 3:Skim items |n); printf( | 4:Modify ite

10、m 5:Search item 6:Delete item |n); printf( | 7:Read file 8:Save item 0:Exit system |n); printf( *n); printf(nt Please choose the number which you WANT:); scanf(%d,&i); return(i);具体实现:主要表现了主函数的菜单,供用户选择。1选项是建立链表并且创建多个新记录2选项是在链表后面追加若干个记录3选项是浏览存储的记录4选项是修改已有的记录5选项是查找记录6选项是删除系统中的记录7选项是从外部文件读取记录8选项是保存记录到外部

11、文件0选项是推出系统creat.c#include extern int n;struct addbok *creat(void) /*引用结构体addbok*/ int i=2; struct addbok *p1,*p2,*head; float a; p1=p2=(struct addbok *)malloc(LEN); head=NULL; system(cls); printf(n=Enter a new record,STOP by0=); printf(n); printf(NO.1: n); printf(Num.:); scanf(%ld,&p1-num); if(p1-nu

12、m=0) printf(nn); printf(nWritten overn); getch(); system(cls); return(head); printf(Name:); scanf(%s,p1-nam); printf(Tel.:); scanf(%s,p1-tel); printf(Sex:); scanf(%s,p1-sex); printf(Age:); scanf(%d,&p1-age); printf(Birthday:); scanf(%s,p1-bir); printf(Dormitory:); scanf(%s,p1-dor); while(p1-num!=0)

13、n=n+1; if(n=1) head=p1; else p2-next=p1; p2=p1; p1=(struct addbok *)malloc(LEN); printf(n); printf(NO.%d: n,i); i=i+1; printf(Num.:); scanf(%ld,&p1-num); if(p1-num=0) p2-next=NULL; printf(nn); printf(nWritten overn); getch(); system(cls); return(head); printf(Name:); scanf(%s,p1-nam); printf(Tel.:);

14、 scanf(%s,p1-tel); printf(Sex:); scanf(%s,p1-sex); printf(Age:); scanf(%d,&p1-age); printf(Birthday:); scanf(%s,p1-bir); printf(Dormitory:); scanf(%s,p1-dor); p2-next=NULL; printf(nn); printf(nWritten overn); getch(); system(cls); return(head);具体实现:创建链表并且输入若干个记录,返回菜单使用“0”。add.c#include extern int n;

15、struct addbok *add(struct addbok *head) struct addbok *p1,*p2,*p0; float a; int yy=1; system(cls); printf(nThe records you entered will be add to the last record.n);while(yy!=0) p1=(struct addbok *)malloc(LEN); p0=p2=head; printf( =Enter a new record=n); printf(n); printf(Num.:); scanf(%ld,p1-num);

16、printf(Name:); scanf(%s,p1-nam); printf(Tel.:); scanf(%s,p1-tel); printf(Sex:); scanf(%s,p1-sex); printf(Age:); scanf(%d,&p1-age); printf(Birthday:); scanf(%s,p1-bir); printf(Dormitory:); scanf(%s,p1-dor); if(p2=NULL) n=n+1; head=p1; p1=NULL; else if (p2-next=NULL) n=n+1; p2-next=p1; p1-next=NULL; e

17、lse while(p2-next!=NULL) p0=p2; p2=p2-next; n=n+1; p2-next=p1; p1-next=NULL; printf(n -Written over-n); printf(nEnter0to the menu,Any key go on: ); scanf(%d,&yy);system(cls); return(head);具体实现:追加记录,具体操作方法和creat.c一样del.c#include extern int n;struct addbok *del(struct addbok *head) struct addbok *p1,*

18、p2; long num; int yy=1; system(cls); printf(n=Delete record=n); while(yy!=0) if(head=NULL) printf(nEmptyn); goto end; printf(nEnter the num. you want to delete:); scanf(%ld,&num); p1=head; while (num!=p1-num&p1-next!=NULL) p2=p1;p1=p1-next; if(num=p1-num) if(p1=head) head=p1-next;n=n-1;printf(n-Dele

19、te-n);goto end; else p2-next=p1-next;n=n-1;printf(n-Delete-n);goto end; else printf(nSorry,can not find the record!n);goto end;end:printf(nEnter0to the menu,Any number go on: );scanf(%d,&yy); system(cls); return(head);具体实现:删除记录。在没有记录的时候系统将会给出提示“空”,若有记录则按照记录的学生编号删除,若没有用户输入的学生则显示找不到该记录。modify.c#includ

20、e extern int n;struct addbok *modify(struct addbok *head) struct addbok *p1,*p2; long num; int x,yy=1; float a; p1=head; system(cls); printf(n=Modify a record=n); if(head=NULL) printf(n =No record now=n); return(head); printf(nPlease input the Num.:); scanf(%ld,&num); while (num!=p1-num&p1-next!=NUL

21、L) p2=p1;p1=p1-next; if(num=p1-num) printf(nHOHO!The Record you want is below:n); printf(%-12s%-12s%-12s%-10s%-10s%-10s%-12s,Num.,Name,Tel.,Sex,Age,Birthday,Dormitory); printf(%-12ld%-12s%-12s%-10s%-10d%-10s%-12sn,p1-num,p1-nam,p1-tel,p1-sex,p1-age,p1-bir,p1-dor); printf(n=n); while(yy!=0) printf(n*

22、Which one do you want to Modify?*n); printf( 1:Num. 2:Name n); printf( 3:Tel. 4:Age n); printf(n*n); printf(your choose:); scanf(%d,&x); switch(x) case 1: printf(Origin Num.:%ldn,p1-num); printf(Please input a new Num.:); scanf(%ld,&num); p1-num=num; printf(n*Success!*n); break; case 2: printf(Origi

23、n namen,p1-nam); printf(nPlease input a new name:); scanf(%s,p1-nam); printf(n*Success!*n); break; case 3: printf(Origin Tel.:%s =n,p1-tel); printf(nPlease input a new Tel.:); scanf(%s,p1-tel); printf(n*Success!*n); break; case 4: printf(Origin age:%d =n,p1-age); printf(nPlease input the new age:);

24、scanf(%d,&p1-age); printf(n*Success!*n); break; printf(nEnter0to the menu,Any number go on: ); scanf(%d,&yy); else printf(nSorry,can not find the record you want!n);getch(); system(cls); return(head);具体实现:用了switch语句实现了按照学生编号,学生姓名,学生电话,学生年龄这4项功能的修改。修改的记录将替换原有的记录。read.c#include extern int n;struct add

25、bok *read(void) int i; struct addbok *p1,*p2,*kt; FILE *fp; system(cls); fp=fopen(addbok.txt,rb); n=getw(fp); p1=p2=(struct addbok *)malloc(LEN); kt=p1; fread(p1,sizeof(struct addbok),1,fp); for(i=0;inext=p1; p2=p1; fread(p1,sizeof(struct addbok),1,fp); /*读写一个数据块*/ fclose(fp); printf(n=Already Reading=nn); getch(); return (kt); 具体实现:从外部文件读取addbok.txt,addbok.txt是保存了用户所输入的记录的文件。其中for语句有点

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1