图书信息管理系统

时间:2022-10-13 09:23:51

图书信息管理系统

摘要:对于学校内的图书信息的管理系统,其数据不仅量大、复杂而且经常变化,若采用传统的手工方式管理,不仅效率低、容易出错,而且管理不规范。随着计算机技术在管理应用领域的发展,开发图书信息的管理系统是十分必要的,并且具有可行性。C 语言具有开发数据处理软件的能力,故本系统选用VC6.0作为开发平台,在VC6.0的环境下,选用C语言完成了此系统的设计、调试及运行。该程序,能完成图书信息的录入、显示、删除以及查找等功能,还可以对现有书籍进行相关的统计,以便更好的掌握现有图书的情况。

关键词:VC6.0C语言 图书 信息管理系统

一、前言:

众所周知,信息存储的主要媒介之一,就是图书,它是信息得以传递的最主要的传统工具,众多的文献、知识靠此,得以流传至今。

随着社会的高速发展,信息量也随之不断增长,为了存储这些信息,图书的数量以及规模将比以往都要庞大很多,因此,在管理图书的方法上应该行之有效的推陈出新,产生一些高效的手段。

传统的人工式图书管理方法,相信大家已经非常熟悉,无外乎将现有的书籍记录在案,并贴上标签,制作书卡;借书时,记录下所借书籍的相关信息,并将借书者的借阅证扣留,与之相对应的书卡共同存放;当还书时,根据书籍信息,找到相应的书卡及借阅证,归还借书者的借阅证,并记录还书信息。可见传统的管理方法很繁琐,而且效率很低,不足之处显而易见。

随着计算机的普及与发展,如果采用计算机来处理这些流程,将能使检索更迅速,查找更方便,存储量更大,可靠性更高,保密性更好,成本更低廉,这无疑是一个高效的、可行的方法。

二、需求分析:

由计算机完成图书信息的管理,要求应实现如下功能:图书信息的输入、输出、删除、统计、查找等功能,每个图书的相关信息包括:编号、书名、作者姓名、出版社、价格等。

三、软件结构:

图书信息的管理系统要求实现多种功能,可将软件设计任务分为多个容易解决的小的子功能模块进行设计。结构如下:

四、模块功能说明及对应操作界面:

主程序模块实现功能:完成主菜单的显示,及对各模块的调用。

输入模块:通过键盘输入某本/多本(最多50本)图书的信息;

输出模块:将所存图书的信息在显示器上显示出来;

删除模块:给定图书编号,删除该本图书的信息;

查找模块:给定图书编号/作者/出版社,显示该本图书的信息;

统计模块:给定图书作者,显示该作者共有多少图书;

五、主要模块流程图:

查找模块:

删除模块:

六、各功能模块编码:

#include

#include

#include

#include

#define MUNMAX 50

struct bookInfo

{//结构类型定义

int num;

char* name;

char* pname;

char* wname;

int* price;

};

struct bookType{

bookInfo book[MUNMAX];

int num;

};

void DisplayMenu();

int choiceItem();

void Init(struct bookType*);

void PrintInfo(struct bookType);

void Print_aInfo(struct bookType,int);

int Search_pname(struct bookType book);

void Input_allInfo(struct bookType*,int num);

int Search_num(struct bookType);

void Input_aInfo(struct bookInfo* as);

int Search_wname(struct bookType book);

void count(struct bookType book);

void main()

{

struct bookType book;

int choice,index;

Init(&book);

do{

choice=choiceItem();

switch (choice){

case 0:printf("\nWelcome to");break;

case 1:printf("\n每输完一个信息后加回车");

Input_allInfo(&book,1); break;

case 2:printf("\n每输完一个信息后加空格,输完整本书的信息后加回车");

Input_allInfo(&book,MUNMAX);break;

case 3:Init(&book);break;;

case 4:PrintInfo(book);break;

case 5:if ((index=Search_pname(book))!=-1)

Print_aInfo(book,index);

else printf("\n No eixst the book.");

break;

case 6:if ((index=Search_num(book))!=-1)

Print_aInfo(book,index);

else printf("\n No eixst the book.");

break;

case 7:if ((index=Search_wname(book))!=-1)

Print_aInfo(book,index);

else printf("\n No eixst the book.");

break;

case 8:

{

int a,b=0;

printf("please input the number!\n");

scanf("%d",&a);

for(int i=0;i

{

if(book.book[i].num==a) b++;

}

if(b==0) printf("\n No eixst the book.");

else

{

for(i=a;i

{

book.book[i]=book.book[i+1];

}

book.num--;

printf("\ndelete finish!");

}

};break;

case 9:count(book);break;

}

}while(choice);

}

void DisplayMenu() //显示菜单

{

printf("\n========= MENU =========");

printf("\n Input a book's informations ...................... 1");

printf("\n Input more books' informations ................... 2");

printf("\n Init book's informationsore..................... 3");

printf("\n Print book's informations....................... 4");

printf("\n Search book's information in print's name ........ 5");

printf("\n Search book's information in number .............. 6");

printf("\n Search book's information in writer's name ....... 7");

printf("\n Delete a book's information ...................... 8");

printf("\n count the number of the book in writer's name .... 9");

printf("\n exit system ...................................... 0");

printf("\nchoice,please:");

}

int choiceItem()//菜单选择

{

int choice;

do{

DisplayMenu();

scanf("%d",&choice);

}while(choice10);

return choice;

}

void Init(struct bookType* s) //初始化

{

s->num=0;

}

void Print_aInfo(struct bookType s,int index)//输出一本书的信息

{

printf("\n书号 书名 出版社作者价格");

printf("\n%4d%-8s",s.book[index].num,s.book[index].name);

printf(" %-8s",s.book[index].pname);

printf(" %-8s",s.book[index].wname);

printf(" %-4d",s.book[index].price);

}

void PrintInfo(struct bookType s)//输出所有书的信息

{

if (s.num==0) {

printf("\nNo book.");

return;

}

for (int i=0;i

printf("\n书号 书名 出版社 作者价格 ");

printf("\n%4d%-8s",s.book[i].num,s.book[i].name);

printf("%-8s",s.book[i].pname);

printf("%-8s",s.book[i].wname);

printf("%-4d",s.book[i].price);

}

}

void Input_aInfo(struct bookInfo* as)//输入一本书的信息

{

printf("\n输入信息分别为:书号 书名 出版社 作者 价格!\n");

scanf("%d",&as->num);

as->name=(char*)malloc(30);

scanf("%s",as->name);

as->pname=(char*)malloc(30);

scanf("%s",as->pname);

as->wname=(char*)malloc(30);

scanf("%s",as->wname);

as->price=(int*)malloc(30);

scanf("%d",&as->price);

}

void Input_allInfo(struct bookType* s,int num)//输入多本书的信息

{

printf("\nEnter %d infomations.\n",num);

for (int i=0;i

if (s->num==MUNMAX){

printf("\nOverflow.");

break;

}

Input_aInfo(&s->book[s->num++]);

}

}

int Search_num(struct bookType book)//用书号查找

{

int num;

printf("\nEnter num:");

scanf("%d",&num);

for (int i=0;i

if (book.book[i].num==num)

return i;

return -1;

}

int Search_pname(struct bookType book)//用出版社查找

{

char pname[80];

printf("\nEnter print's name:");

scanf("%s",pname);

for (int i=0;i

if (strcmp(book.book[i].pname,pname)==0)

return i;

return -1;

}

int Search_wname(struct bookType book)//用作者查找

{

char wname[80];

printf("\nEnter writer's name:");

scanf("%s",wname);

for (int i=0;i

if (strcmp(book.book[i].wname,wname)==0)

return i;

return -1;

}

void count(struct bookType book) //统计

{

char wname[80];

int b=0;

printf("\nEnter writer's name:");

scanf("%s",wname);

for (int i=0;i

if (strcmp(book.book[i].wname,wname)==0)

b++;

printf("\n %s has %d books!",wname,b);

}

注:文章内所有公式及图表请以PDF形式查看。

上一篇:大学毕业生“三支一扶”服务网的整体设计 下一篇:大寨河一级电站边坡稳定性计算与防治