数据结构课程设计报告要求及模板1.docx
《数据结构课程设计报告要求及模板1.docx》由会员分享,可在线阅读,更多相关《数据结构课程设计报告要求及模板1.docx(34页珍藏版)》请在冰点文库上搜索。
数据结构课程设计报告要求及模板1
数据结构课程设计报告撰写要求
(一)纸张与页面要求
1.采用国际标准A4型打印纸或复印纸,纵向打印。
2.封页和页面按照下面模板书写(正文为:
小四宋体1.5倍行距)。
3.图表及图表标题按照模板中的表示书写。
(二)课设报告书的内容应包括以下各个部分:
(按照以下顺序装订)
1.封页(见课设模版)
2.任务书(学生教师均要签字,信息填写完整)
3.目录
4.正文一般应包括以下内容:
(1)题目介绍和功能要求(或描述)
课程设计任务的详细描述(注意不能直接抄任务书),将内容做更详细的具体的分析与描述;
(2)系统功能模块结构图
绘制系统功能结构框图及主要模块的功能说明;
(3)使用的数据结构的描述:
数据结构设计及用法说明;
(4)涉及到的函数的描述;
(5)主要算法描述(程序流程图)
(6)给出程序测试/运行的结果
设计多组数据加以描述(包括输入数据和输出结果)
(7)参考文献
格式要求:
[序号]作者,等.书名.出版地:
出版社,出版年
5.附录:
程序清单(应带有必要的注释)
6.课程设计的总结及评语
沈阳航空航天大学
课程设计报告
课程设计名称:
数据结构课程设计
课程设计题目:
个人事务提醒工具软件设计
院(系):
计算机学院
专业:
网络工程
班级:
14010201
学号:
2011040102004
姓名:
李舒敏
指导教师:
许清
装订时:
此页为任务书
1概要设计
1.1题目介绍和功能要求
内容:
个人事务提醒工具软件设计
主要功能:
1)设置日历,利用日历实现事务的记录,应该具有输入年份月份既有查看当时日历的功能。
2)设置日程安排与提醒,其中应该包括年月日,小时,分钟等信息和日程安排的文本信息。
3)统计和查询功能。
日程管理系统应该具有查看所有日程和统计日程的功能,同时删除日程也是必不可少的。
要求:
1)熟悉文件的理论和操作方式,包括文件的读取,写入等等。
2)学习电子日历的制作和储存方式。
3)设置时钟,做时间的比较处理,定时报警。
了解获取系统的时间的方法和做比较处理的方法。
4)熟练运用开发环境。
熟练掌握调试分析的方法。
5)完成软件的设计和编码。
6)熟练掌握基本调试的方法。
7)提交符合课程设计规范的报告。
2系统设计
2.1总体结构
本程序主要分为六个模块(功能模块见图2.1.1)菜单模块,日历模块,查看模块,新建模块,删除模块,提醒模块。
菜单模块:
显示其他功能,是进入其他模块的途径。
日历模块:
显示系统时间所示月份的日历,输入其他时间也可显示其他月份年份日历。
查看模块:
查看所有的日程包括时间和日程安排的文本。
新建模块:
输入时间和日程安排,并且按时间先后重新写入文件。
删除模块:
显示所有的日程并排序,输入需要删除日程的编号,将删除后的链表写入文件。
提醒模块:
监控键盘动作,键盘无动作时进入此模块,实现后台功能,将读取的日程时间与系统时间对比,成功则显示提示话语及音乐。
图2.1.1函数设计表
2.2数据结构设计及用法说明
本程序主要用链表存储从文件读出的数据:
structlist
{
intdata[6];
chartitle[31];
structlist*next;
};
此为链表节点数据类型的定义。
其中整形数组data[6]分别存储年,月,日,时,分,提醒次数。
字符型数组titile[31]存储日程安排。
2.3函数设计
1)本函数设计见表2.3.1。
函数名称
函数原型
功能描述
main
intmain
主函数,主菜单功能
writefile
voidwritefile
把链表的数据写入文件中
bibibi
voidbibibi
提醒模块中的提示语言和音乐
clocking
voidclocking
不断读取系统时间和已存入的日程时间比较
view
structlist*view
读取文件中日程到链表中并显示
rili
voidrili
显示日历
cnewnode
voidcnewnode
在链表中创建新日程
chakan
voidchakan
查看所有日程并排序
deleterc
voiddeleterc
删除链表中的特定日程
图2.3.1函数设计表
2)本程序函数调用关系如2.3.2函数调用图所示。
图2.3.2函数设计图
2.4关键流程
1)系统主菜单流程图(如2.4.1)主要使用while
(1)循环达到菜单的目的,输入0,则退出系统。
键盘无动作时进入提醒模块,已达到后台的目的。
图2.4.1主菜单流程图
2)日历模块(流程图见2.4.2),首先获取系统时间,用数组month[12]储存每月的天数,首先判断年份是否为闰年,再利用公式判断当月第一天是星期几。
再依次打印出日历。
图2.4.2日历流程图
3)查看模块(见流程图2.4.3)读取文件内容到链表中,再打印出来。
图2.4.3查看流程图
3)新建模块(见图2.4.4)先将文件内容读入链表中,输入新建的日程,和已存在日程比较,按时间顺序插入链表中,再将链表写入文件。
图2.4.4新建流程图
5)删除模块(见2.4.5删除流程图)读取文件内容到链表,调用查看函数,打印日程并编号,用户输入需要删除的日程编号即可删除。
图2.4.5删除流程图
6)提醒模块(流程图见2.4.5)键盘无动作时,从文件中读取内容到链表,不断获取系统时间与链表中时间对比,若相同则显示提示语言和音乐。
图2.4.6删除流程图
3调试分析
1)问题一
问题描述:
在显示模块中,除了输入的日程,显示多个乱码。
问题分析:
经过调试后,我分析是写入文件出错。
对于时间我使用的是fwrite函数,对于日程文本我使用fputc。
经分析fwrite函数没有出错。
后来经过仔细分析检查,发现我把字符串结尾符‘\0’误以为等价于‘‘。
导致写入文件出错。
问题解决:
把写入的循环条件while(ch!
=’’)改成while(ch!
=’\0’)即可。
2)问题二
问题描述:
在提醒模块中,日程时间到了,却不显示提示语言和音乐。
问题分析:
经过跟踪发现,在时间比对的地方出错。
经过查阅资料,time_tnow获取的系统时间是从1900年开始算起的,获取的月份信息是从0开始,所以,才会在时间比对上出现错误。
问题解决:
在时间比对的if语句中把timenow->year+1900,timenow->mon+1,问题解决。
3)问题三
问题描述:
在返回菜单后,直接到switch语句中的default里。
问题分析:
在上一级操作中只读取了一个字符,剩余一个‘\n’在缓存里,导致回到主菜单中,在没有输入的情况下,读取了这个字符。
问题解决:
在switch语句下面多加一条语句ch=getchar();读取这个‘\n’字符,即可解决这个问题。
4测试及运行结果
1)主菜单界面如4.1所示,按照图示信息输入字符即可进入各个模块。
图4.1主菜单演示图
2)日历界面如4.2所示,按照提示信息可查看其它月份的日历。
图4.2日历模块演示图
3)添加模块如4.3所示,按照提示语言进行输入,可持续输入。
图4.3添加模块演示图
4)查看模块如4.4所示。
图4.4查看模块演示图
5)删除模块如4.5所示。
图4.5查看模块演示图
6)提醒模块如4.6所示。
图4.5提醒模块演示图
参考文献
[1]H.M.DeitelP.J.Deitel.C语言设计教程[M].北京:
机械工业出版设,2001
[2]王敬华林萍张清国.C语言设计教程[M].北京:
清华大学出版社,2009
[3]严蔚敏.吴伟民.数据结构(C语言版)[M].北京:
清华大学出版社,2007
附录(程序清单)
#include
#include
#include
#include
#pragmacomment(lib,"WINMM.LIB")
#include
#include
structlist
{
intdata[6];//year,month,day,hour,min,cishu
chartitle[31];
structlist*next;
};
voidwritefile(structlist*head)//将链表写入文件
{
structlist*p1;
FILE*fp;
p1=head->next;
fp=fopen("schedule.txt","w");
while(p1!
=NULL)
{
fwrite(p1->data,sizeof(int),6,fp);
fprintf(fp,"%s",p1->title);
fputc('\0',fp);
p1=p1->next;
}
fclose(fp);
return;
}
voidbibibi(structlist*p2)//日程到期提示语及提示音
{charch;
system("cls");
printf("到时间啦~\(≧▽≦)/~\n");
printf("日期:
%d-%d-%d\n",p2->data[0],p2->data[1],p2->data[2]);
printf("时间:
%d:
%d\n",p2->data[3],p2->data[4]);
printf("日程安排:
%s\n",p2->title);
printf("按0返回");
while
(1)
{PlaySound("提示音\\7.wav",NULL,SND_ASYNC|SND_LOOP);
if(kbhit())
{
ch=getchar();
ch=getchar();
return;
}
}
}
voidclocking()//读取文件时间与系统时间对比
{
time_tnow;//实例化time_t结构
structtm*timenow;
structlist*head,*p1,*p2;
FILE*fp;
charch;
inti;
time(&now);
timenow=localtime(&now);
if((fp=fopen("schedule.txt","r"))==NULL)
return;
head=(structlist*)malloc(sizeof(structlist));
head->next=NULL;
p1=head;
p2=(structlist*)malloc(sizeof(structlist));//从文件中读取日程安排
fread(p2->data,sizeof(int),6,fp);
while(!
feof(fp))
{
ch=fgetc(fp);
i=0;
while(ch!
='\0')
{
p2->title[i]=ch;
ch=fgetc(fp);
i++;
}
p2->title[i]='\0';
p1->next=p2;
p1=p2;
p2=(structlist*)malloc(sizeof(structlist));
fread(p2->data,sizeof(int),6,fp);
}
p1->next=NULL;
fclose(fp);
if(head->next==NULL)return;
p2=head->next;
p1=head;
while
(1)
{
if(p2->data[0]==timenow->tm_year+1900&&p2->data[1]==timenow->tm_mon+1&&p2->data[2]==timenow->tm_mday&&
p2->data[3]==timenow->tm_hour&&p2->data[4]==timenow->tm_min)
{
p2->data[5]--;
bibibi(p2);
if(p2->data[5]==0)//若提醒次数达到则删除此日程
{
p1->next=p2->next;
free(p2);
p2=p1;
}
else
{
p2->data[4]=p2->data[4]+5;
}
writefile(head);
return;
}
p1=p2;
p2=p2->next;
if(kbhit())//键盘有动作则回到
return;
if(p2==NULL)
{
p1=head;
p2=p1->next;
}
time(&now);
timenow=localtime(&now);
}
return;
}
structlist*view()
{
FILE*fp;
structlist*head,*p1,*p2;
charch;
inti,count;
if((fp=fopen("schedule.txt","r"))==NULL)
printf("日程为空!
\n");
else
{
head=(structlist*)malloc(sizeof(structlist));
head->next=NULL;
p1=head;
p2=(structlist*)malloc(sizeof(structlist));//从文件中读取日程安排
fread(p2->data,sizeof(int),6,fp);
while(!
feof(fp))
{
ch=fgetc(fp);
i=0;
while(ch!
='\0')
{
p2->title[i]=ch;
ch=fgetc(fp);
i++;
}
p2->title[i]='\0';
p1->next=p2;
p1=p2;
p2=(structlist*)malloc(sizeof(structlist));
fread(p2->data,sizeof(int),6,fp);
}
fclose(fp);
p1->next=NULL;
p1=head->next;
count=0;
while(p1!
=NULL)
{
count++;
printf("第%d个:
\n",count);//打印日程
printf("日期:
%d-%d-%d\n",p1->data[0],p1->data[1],p1->data[2]);
printf("时间:
%d:
%d\n",p1->data[3],p1->data[4]);
printf("次数:
%d\n",p1->data[5]);
printf("日程内容:
\n");
printf("");
i=0;
while(p1->title[i]!
='\0')
{
printf("%c",p1->title[i]);
i++;
}
printf("\n\n\n\n");
p1=p1->next;
}
if(count==0)
printf("日程为空!
\n");
returnhead;
}
}
intrili(intyear,intmon)//查看日历
{
intjudge,monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31},i,weekday,d;
charinput;
time_tnow;//实例化time_t结构
structtm*timenow;
system("cls");
time(&now);
timenow=localtime(&now);
if(year%4==0&&year%100!
=0)
{
judge=1;
monthday[1]=29;
}
elseif(year%100==0&&year%400==0)
{
judge=1;
monthday[1]=29;
}
else{
judge=0;
monthday[1]=28;
}
printf("%d年%d月\n",1900+year,mon+1);
printf("SunMonTueWenThuFriSat\n");
printf("");
weekday=0;
for(i=0;iweekday=weekday+monthday[i];
weekday++;
year=year+1900;
d=year-1+(year-1)/4-(year-1)/100+(year-1)/400+weekday;//计算月份中的第一天是星期几
if(d>7)
d=d%7;
for(i=0;iprintf("");
for(i=1;i<=monthday[mon];i++)
{
printf("");
printf("%3d",i);
d++;
if(d>=7)
{
d=d%7;
printf("\n");
printf("");
}
}
printf("\n");
printf("查看其它日期请按1\n");
printf("返回请按0\n");
clocking();
input=getchar();
input=getchar();
if(input=='1')
{
printf("请按示例格式输入日期例如2012-12\n");
scanf("%d-%d",&year,&mon);
rili(year-1900,mon-1);
}
if(input=='0')return0;
return0;
}
voidcnewnode(structlist*head)//创建日程链表新节点
{
inttemp[6],flag,i;
structlist*p1,*p2;
charx[31],ch;
system("cls");
printf("\n\n\n\n\n");
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
printf("\n");
printf("欢迎进入个人事务提醒系统o(≧v≦)o\n");
printf("\n");
printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n");
printf("请输入日期,例如2012-12-12\n");
clocking();
scanf("%d-%d-%d",&temp[0],&temp[1],&temp[2]);
printf("请输入时间,例如:
24:
00\n");
scanf("%d:
%d",&temp[3],&temp[4]);
printf("请输入提醒次数\n");
scanf("%d",&temp[5]);
printf("请输入日程安排:
\n");
ch=getchar();
gets(x);
p2=head->next;
p1=head;
while(p2!
=NULL)
{flag=1;
for(i=0;i<5;i++)//找到日程插入位置
{
if(temp[i]data[i])
{
flag=0;break;
}
}
if(flag==0)break;
else
{
p1=p2;
p2=p2->next;
}
}
p2=(structlist*)malloc(sizeof(structlist));
for(i=0;i<6;i++)
{
p2->data[i]=temp[i];
}
strcpy(p2->title,x);
p2->next=p1->next;
p1->next=p2;
writefile(head);
return;
}
voidcreatenew()
{FILE*fp;
structlist*head,*p1,*p2;
charinput,ch;
inti;
head=(structlist*)malloc(sizeof(structlist));
head->next=NULL;
p1=head;
if((fp=fopen("schedule.txt","r+"))!
=NULL)
{p2=(structlist*)malloc(sizeof(structlist));//读取文件,解决feof中多读的问题
fread(p2->data,sizeof(int),6,fp);
while(!
feof(fp))
{i=0;
while((ch=fgetc(fp))!
='\0')
{p2->title[i]=ch;
i++;
}
p2->title[i]='\0';
p1->next=p2;
p1=p2;
p2=(structlist*)malloc(sizeof(structlist));
fread(p2->data,sizeof(int),6,fp);
}
fclose(fp);
p1->next=NULL;
}
cnewnode(head);
printf("添加成功!
\n继续添加请按1,返回主菜单请按0\n");
input=getchar();
while
(1)
{
switch(input)
{
case'1':
cnewnode(head);printf("添加成功!
\n继续添加请按1,返回主菜单请按0\n");
input=getchar();
break;
case'0':
return;
}
}
}
voidchakan()//查看所有日程
{
charinput;
structlist*head;
system("cls");
printf("\n\n\n\n\n");
printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
printf("\n");
printf("欢迎进入个人事务提醒系统o(≧v≦)o\n");
printf