图书信息管理系统实验报告书Word文档下载推荐.docx

上传人:b****7 文档编号:22312420 上传时间:2023-02-03 格式:DOCX 页数:42 大小:332.33KB
下载 相关 举报
图书信息管理系统实验报告书Word文档下载推荐.docx_第1页
第1页 / 共42页
图书信息管理系统实验报告书Word文档下载推荐.docx_第2页
第2页 / 共42页
图书信息管理系统实验报告书Word文档下载推荐.docx_第3页
第3页 / 共42页
图书信息管理系统实验报告书Word文档下载推荐.docx_第4页
第4页 / 共42页
图书信息管理系统实验报告书Word文档下载推荐.docx_第5页
第5页 / 共42页
点击查看更多>>
下载资源
资源描述

图书信息管理系统实验报告书Word文档下载推荐.docx

《图书信息管理系统实验报告书Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《图书信息管理系统实验报告书Word文档下载推荐.docx(42页珍藏版)》请在冰豆网上搜索。

图书信息管理系统实验报告书Word文档下载推荐.docx

需求分析

本次C语言程序设计以“图书馆管理系统”为题,题目要求开发一个图书信息管理系统,图书信息包括:

图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己的当前能力进行扩充).

基本功能包括:

(1)图书信息录入功能(图书信息用文件保存)--输入

(2)图书信息浏览功能--输出

①按书名查询②按作者名查询③ 按照价钱排序 ④按出版时间排序等等

当然,也可以根据个人的情况进行适当的扩展:

比如权限处理啊,报表打印功能,模糊查询,统计功能,或筛选出小于指定数量库存的图书等等。

测试数据有ASCII文件tushu_list.txt提供:

tushu_list.txt文件结构:

(无序)

图书编号 书名 作者 出版社 类别   出版社时间价格

——-—-——--—---———--—-———-—-----——-—-—--———-———----——--—-——---—-—-—--—

1001  三国演义   罗贯中 民族文学出版社  小说158555。

5

1008  孟子     孟子   人民教育出版社古籍1981   23。

33

1002水浒传 施耐庵 民族文学出版社小说158248.36

1003  西游记  吴承恩  民族文学出版社 小说160246.38

1006 线性代数同济   同济大学出版社教育201019。

98

1010新视野   郑树棠 外研社 教育2009  32。

90

1007 春秋  孔子人民教育出版社古籍1980 22。

22

1009 时间简史  霍金 外研社  科普   197735。

31

1004红楼梦 曹雪芹民族文学出版社 小说  162149。

59

1005 高等数学 同济 同济大学出版 教育 201029.6

二概要设计

(1)。

数据结构

根据题目给定的图书信息和数据格式可知道,链表结点必须用结构体实现。

故:

首先建立结构体数组:

structtushu{

ﻩcharnum[10];

  字符型图书编号

charname[20];

   字符型书名

char writer[20];

   字符型作者

ﻩchar press[20];

  字符型出版社

ﻩcharkind[20];

  字符型类别

ﻩdoubletime;

 双精度实型出版时间

ﻩdouble price;

  实型价格

struct tushu*next;

 用与构建连表指向下一结点

};

FILE *fp;

   定义全局变量fp

(2).模块划分

定义全局变量:

FILE*fp;

 /*定义全局变量fp*/

函数原型清单:

/*密码验证*/

voidsecret();

 

/*主菜单*/

voidmenu();

/*录入图书信息*/

struct tushu*Input();

/*将信息导入文件可追加*/

voidfprint(structtushu*head);

/*将信息导入文件只写(可覆盖)*/

voidfprint_(struct tushu*head);

/*从tushu_list中读取数据构建链表*/

structtushu *create(structtushu* head,int*n);

/*浏览全部图书信息*/  

voidBrowse(structtushu*head);

/*统计图书数目*/

voidcount(structtushu *head);

/*按书名查询图书*/

voidFindofname(structtushu*head);

/*按作者查询图书*/

voidFindofwriter(structtushu*head);

/*按类别查询图书*/

voidFindofkind(struct tushu*head);

 

/*按出版时间排序*/

voidSort_time(structtushu*head);

/*按价格排序*/

voidSort_price(struct tushu*head);

/*按图书编号排序*/

void Sort_num(structtushu*head);

/*按编号删除图书*/

structtushu*Delete(structtushu*head,charm[15]);

/*修改图书*/

struct tushu*Revise(structtushu*head);

(3).程序总体框架

模块层次结构只确定了模块之间的关系以及函数原型,不是程序的执行步骤。

程序的总体框架是程序的总体流程图。

此程序并非是按照顺序逐一执行的,其中有某些程序他们之间的关系并不是递进,而是并列。

所以选取一个合适的菜单是最佳方案。

程序的总体框架如下:

由主函数进入程序

密码验证

通过后输出主菜单

图书馆图书管理系统

0-退出系统6-按类别查询

1-添加新图书7-按时间排序

2-浏览图书8-按价格排序

3-统计图书数目9-按编号排序

4-按书名查询10-按编号删除图书

5-按作者查询11-修改图书

未通过

输入对应编号

0-退出系统

1-添加新图书

2-浏览图书

3-统计图书数目

4-按书名查询

5-按作者查询

6-按类别查询

7-按时间排序

8-按价格排序

9-按编号排序

10-按编号删除图书

11-修改图书

三.功能模块的详细设计

主菜单

1。

函数原型,功能及形参说明

函数原型:

voidmenu()

函数功能:

实现系统的菜单调用,显示对应选项

参数说明:

函数类型为空

2.程序清单

void menu()

{

 printf(”\n**************************************************\n”);

ﻩprintf(” 图书馆图书管理系统    \n”);

ﻩprintf(”—--—--—---—----——-—--—----——-———-—-————-—---———--—-\n”);

printf("  0-退出系统 6-按类别查询  \n”);

ﻩprintf("

    1-添加新图书 7-按时间排序  \n”);

ﻩprintf(”  2—浏览图书 8-按价格排序   \n”);

printf(” 3—统计图书数目9-按编号排序  \n”);

ﻩprintf("

   4—按书名查询  10-按编号删除图书   \n”);

printf(”     5—按作者查询  11—修改图书     \n”);

ﻩprintf(”—-—----——---——-----—-—---——————--—————-——--—--——-—-\n”);

__________________________________________________\n"

);

}

1.函数原型,功能及形参说明

函数原型:

voidsecret()

函数功能:

实现系统的密码验证功能

chara[20]20个字符以内的密码输入

   system(”cls"

);

  库函数清频

2.程序清单

void secret()

char a[20];

ﻩprintf(”**进入图书管理系统前请先进行密码验证—--”);

ﻩdo{

ﻩﻩgets(a);

        /*输入密码*/

system("cls”);

    /*调用库函数清屏*/

printf("

对不起!

您输入的密码有误,请重新输入———"

}while(strcmp(a,"

0605")!

=0);

 /*单一密码“0605”*/

system("cls"

ﻩprintf(”    欢迎进入图书管理系统\n”);

添加新图书及是否保存

structtushu*Input()

实现图书的添加及保存(其中调用函数voidfprint(structtushu*head);

/*将信息导入文件可追加*/)

参数说明:

*head 链表头结点指针

  *p1,*p2辅助结点 局外变量

2。

程序清单

/*录入图书信息建立图书信息的链表*/

structtushu*Input()

structtushu*p1,*p2,*head;

/*建立辅助结点及头结点*/

ﻩcharnum;

intn=0,x;

ﻩsystem(”cls"

ﻩmenu();

printf("

\n请按对应项输入图书信息以#结束:

\n");

ﻩp1=(structtushu*)malloc(sizeof(structtushu));

head=p2=p1;

ﻩdo{      /*使用dowhile语句输入图书信息*/

scanf("

%s”,&

p1—>

num);

if(strcmp(p1—〉num,”#”)==0)break;

   /*判断结束符*/

ﻩelse

ﻩﻩﻩscanf("

%s%s%s%s%lf%lf”,

ﻩp1—〉name,p1-〉writer,p1—>

press,p1—〉kind,&p1—>

time,&

p1—>

price);

ﻩnum=’#'

;

      /*?

?

*/

ﻩp1=(structtushu*)malloc(sizeof(structtushu));

ﻩp2-〉next=p1;

ﻩp2=p1;

n++;

}while

(1);

p1—〉next=NULL;

ﻩprintf("图书信息输入结束!

\n”);

getchar();

      

ﻩprintf(”是否保存图书信息?

(1。

是/2.否):

”);

scanf(”%d”,&

x);

ﻩif(x==1)

ﻩfprint(head);

   /*调用函数保存至文件*/

else

ﻩﻩprintf(”\n文件没有被保存!

\n"

ﻩreturnhead;

  /*返回头指针*/

将信息导入文件可追加

voidfprint(structtushu*head)

实现图书的保存将信息导入文件可追加

structtushu*head链表头结点指针

voidfprint(structtushu *head)

structtushu*p1;

ﻩif((fp=fopen(”tushu_list。

txt”,”a"

))==NULL)

{

printf("

File open error!

\n”);

ﻩexit(0);

for(p1=head;

next!

=NULL;

p1=p1->next)/*遍历*/

ﻩfprintf(fp,”%s\t%s\t%s\t%s\t%s\t%.0lf\t%lf\n",

p1—〉num,p1-〉name,p1-〉writer,p1-〉press,p1—>

kind,p1—〉time,p1—〉price);

/*将图书信息写入文件*/

ﻩfclose(fp);

  /*关闭文件*/

ﻩsystem("

cls");

ﻩmenu();

ﻩprintf("

\n图书信息已成功保存到文件 tushu_list。

txt中!

getchar();

将信息导入文件不可追加

void fprint_(structtushu*head)

实现修改及删除后的图书保存将信息导入文件并覆盖原文件

structtushu*head 链表头结点指针

voidfprint_(structtushu*head)

struct tushu*p1;

ﻩif((fp=fopen("

tushu_list.txt”,”w”))==NULL)

ﻩ{

ﻩprintf("

Fileopenerror!

\n”);

ﻩexit(0);

ﻩ}

for(p1=head;

p1!

=NULL;

p1=p1->

next) /*遍历*/

ﻩfprintf(fp,”%s\t%s\t%s\t%s\t%s\t%。

0lf\t%lf\n”,

ﻩp1->

num,p1->

name,p1—〉writer,p1-〉press,p1-〉kind,p1->

time,p1—〉price);

/*将图书信息写入文件*/

ﻩfclose(fp);

  /*关闭文件*/

system("cls");

ﻩmenu();

ﻩprintf("

\n图书信息已成功保存到文件 tushu_list.txt中!

ﻩgetchar();

浏览图书信息

1.函数原型,功能及形参说明

void Browse(structtushu*head)

实现图书信息的输出

structtushu *head链表头结点指针

2。

void Browse(structtushu*head)/*浏览全部图书信息*/

ﻩcharnum[10];

ﻩcharname[20];

ﻩcharwriter[20];

ﻩcharpress[20];

ﻩchar kind[20];

ﻩdoubletime;

doubleprice;

system("

cls"

menu();

if((fp=fopen(”tushu_list。

txt”,”a+”))==NULL)

ﻩ{

ﻩprintf("

Fileopen error!

ﻩexit(0);

ﻩprintf(”——-———---——--——-—-——-——-——-—-—-———--———-—-——-—-———-\n”);

printf("

编号 书名 作者  出版社类别出版时间价格\n”);

while(!

feof(fp))/*读取并输出*/

fscanf(fp,"

%s%s%s%s%s%lf%lf"

num,name,writer,press,kind,&

time,&price);

ﻩ  printf("

%s\t%s\t%s\t%s\t%s\t%.0lf\t%.2lf\n”,

num,name,writer,press,kind,time,price);

ﻩ};

if(fclose(fp))

ﻩprintf(”Cannotclosethefile!

\n"

ﻩexit(0);

从tushu_list中读取数据构建链表

structtushu* create(structtushu*head,int*n)

建立图书信息单向链表

structtushu*head链表头结点指针

     int*n   图书数目指针

struct tushu* create(structtushu*head,int*n)

structtushu*p,*p1,*p2;

ﻩif((fp=fopen("

tushu_list。

txt"

,”a+"

))==NULL)/*先安全打开目录文件*/

ﻩprintf(”File open error!

ﻩexit(0);

ﻩwhile(!

feof(fp))/*读取并创建链表*/

ﻩﻩ(*n)++;

ﻩp=(structtushu *)malloc(sizeof(struct tushu));

ﻩﻩfscanf(fp,”%s%s%s%s%s%lf%lf”,

ﻩﻩp—〉num,p—>

name,p—>

writer,p—〉press,p—>

kind,&

p->

time,&p—>price);

if(head==NULL){

ﻩﻩhead=p;

ﻩﻩp1=p;

ﻩ}

ﻩelse{

ﻩp1—>

next=p;

ﻩﻩp2=p1;

ﻩp1=p;

ﻩ}

}

ﻩp2—>

next=NULL;

ﻩfree(p);

    /*释放辅助结点所占用空间*/

(*n)—-;

fclose(fp);

returnhead;

统计图书数目

函数原型,功能及形参说明

voidcount(struct tushu*head)

实现图书信息数目统计并输出 

structtushu*head  链表头结点指针

  n      计数

voidcount(structtushu*head)/*统计图书数目*/

intn=0;

structtushu*p1;

ﻩhead=create(head,&

n);

    /*调用创建链表函数*/

ﻩfor(p1=head;

p1—〉next!

=NULL;

p1=p1-〉next)  /*遍历*/

ﻩn++;

             /*计数*/

printf(”\n此系统统计在内的图书共有%d册。

\n”,(n+1)/2);

/*计算并输出图书数目*/

按书名查询图书信息

1。

voidFindofname(structtushu*head)

实现图书信息按照书名查询并输出 

struct tushu*head 链表头结点指针

i     计数判定

charb[20];

   查找编号

函数流程图

Findofname

i=0;

输入目标图书名称10[b]

strcmp(p->

name,b)

head!

=NULL遍历

未找到

p=p->

next

i!

=0

输出图书信息

i++

=0;

!

3。

voidFindofname(structtushu*head)/*按书名查询图书*/

ﻩinti=0,n;

   /*i为计数判定*/

ﻩcharb[20];

    /*定义查找编号*/

ﻩstruct tushu*p;

ﻩhead=create(head,&

ﻩp=head;

system(”cls”);

menu();

printf(”\n请输入要查询的图书名称:

"

ﻩscanf("

%s”,b);

while(p!

=NULL){

ﻩif(strcmp(p-〉name,b)==0){/*比较输入的字符串与原文件中书名*/

ﻩprintf("

\n编号 书名   作者出版社类别出版时间价格\n"

ﻩﻩprintf("

%s\t%s\t%s\t%s\t%s\t%.0lf\t%。

2lf\n"

ﻩp-〉num,p—>

name,p—〉writer,p—>

press,p—>

kind,p—>time,p—〉price);

ﻩﻩi++;

ﻩﻩ}

ﻩp=p—〉next;

ﻩif(i==0)

ﻩﻩprintf("

\n对不起!

没有找到名为《%s》的图书!

\n”,b);

按作者查询图书

void Findofwriter(structtushu *head)

实现图书信息按照图书作者查询并输出

structtushu *head 链表头结点指针

voidFindofwriter(struct tushu *head)

inti=0,n;

charb[20];

ﻩstructtushu *p;

head=create(head,&

ﻩp=head;

ﻩsystem("

cls”);

ﻩmenu();

ﻩprintf("

\n请输入要查询的图书作者姓名:

”);

%s”,b);

ﻩwhi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高等教育 > 医学

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

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