c语言 图书管理系统 上机实验报告.docx

上传人:b****6 文档编号:5808098 上传时间:2023-01-01 格式:DOCX 页数:44 大小:25.75KB
下载 相关 举报
c语言 图书管理系统 上机实验报告.docx_第1页
第1页 / 共44页
c语言 图书管理系统 上机实验报告.docx_第2页
第2页 / 共44页
c语言 图书管理系统 上机实验报告.docx_第3页
第3页 / 共44页
c语言 图书管理系统 上机实验报告.docx_第4页
第4页 / 共44页
c语言 图书管理系统 上机实验报告.docx_第5页
第5页 / 共44页
点击查看更多>>
下载资源
资源描述

c语言 图书管理系统 上机实验报告.docx

《c语言 图书管理系统 上机实验报告.docx》由会员分享,可在线阅读,更多相关《c语言 图书管理系统 上机实验报告.docx(44页珍藏版)》请在冰豆网上搜索。

c语言 图书管理系统 上机实验报告.docx

c语言图书管理系统上机实验报告

(此文档为word格式,下载后您可任意编辑修改!

成都信息工程大学计算机系

 

实验课程:

C语言程序设计基础

实验项目:

图书管理系统

指导教师:

李莉丽

学生姓名:

学生学号:

20100

班级:

计算机科学与技术

实验地点:

5201

实验时间:

2011年5月18日

实验成绩:

评阅老师:

一【上机实验目的】

设计并实现该课程设计的目的主要在于:

1)对一定规模的综合软件编程有一定的经历与认识。

在做的过程中,你会发现,提前的规划即分析与设计重要过编程过程,否则会走很多弯。

2)综合并结合现实应用使用C语言的知识。

这个设计会用到C语言这门课的全部知识,其中以文件、数组与链表为主,书中提到的主要及重点算法都会使用到。

3)不仅涉及编程,还涉及到功能分析、模块规划等方面的知识,这些知识在后续课程学习时,会经常使用。

这些知识在学《软件工程》这门课时,会系统讲解。

希望有了这次的经历,你能更好的体会《软件工程》这门课的意义,并能学好和用好其中的知识。

4)每项功能的实现,一般有多种方法,这里都强调使用时空效率最高的方法,此次实现只是让你有一个初步的认识,在下学期学习了《数据结构》后,你就知道为什么让你这样做,你也对《数据结构》这门课的作用及意义有所了解。

二【实验环境】

PC机每人1台

三【上机实验内容】

编写图书管理系统,具有以下基本功能

(1)    各种基本数据的录入。

如:

图书资料基本信息录入等。

(2)  各种基本数据的修改。

即:

允许对以及录入的数据重新进行编辑、修改。

(3)    各种基本数据的插入。

如:

在图书采购信息中插入一条新信息等。

(4)    各种基本数据的删除。

如:

假设某本书遗失且馆藏数为0,删除该书的相关信息等。

(5)    基于各种数据的查询。

如:

书名中含有“计算机”的所有书籍、全部借出的所有图书等。

(6)      基于各种基本数据的统计计算。

四【上机调试程序流程图】(注:

可打印)

五【上机调试中出现的错误信息、错误原因及解决办法】

读写错误:

fopen的时候改成用二进制读写.目前不知道为什么不用二进制不能读写.

六【上机调试后的源程序及还存在的问题】

#include

#include

#include

#include

#include

#include

#defineKey_UP72

#defineKey_DOWN80

#defineKey_ENTER28

#defineKey_N49

#defineKey_Y21

#defineLENsizeof(structlinklist)

typedefstructbook1/*图书基本信息结构体*/

{

charname[20];

charwriter[30];

chartype[20];

charnum[20];

chartime[20];

charpress[20];

charedition[20];

charISBN[40];

floatprice;

intcount;

intlendnum;

}bbasic;

/*

图书资料基本信息:

中图法分类号、图书编号、书名、作者(要考虑多个作者情况)、出版社、出版日期、ISBN、版次、定价、馆藏数、借阅数等。

*/

typedefstructbook2/*图书采购信息结构体*/

{

charname[20];

charwriter[20];

chartime[15];

intnum;

floatprice;

floatmoney;

charbill[30];

}bpurchase;

/*

图书采购信息:

书名、作者、采购日期、采购数量、采购单价、采购金额、发票号码、图书编号等。

*/

typedefstructbook3/*图书借阅信息结构体*/

{

/***************需要输入的信息*********/

charname[20];

charperson[20];

charcompany[20];

charnum[20];/*借书证号*/

charbtime[15];

/**************运算可得信息************/

charrtime[15];

charfine[20];

}blend;

/*

图书借阅信息:

借阅人、借阅人所在单位、借书证号、所借书名、借阅日期、归还日期、逾期罚款等。

借阅期限为一个月,逾期1天,罚款1角。

*/

structlinklist

{

bbasicbinfo;

structlinklist*next;

};

intkey();

voidmenu();

void_window();

voidwords();

voidbox(int,int,int,int);

int_choose(intbot,inttop);

voidplay(int);

intreadsum();

voidadd();

voidaddbook();

voidaddbuy();

voidaddborrow();

voidmanage();

structlinklist*create();

voidmodify();

voiddelete();

voidinsert();

voidsearch();

voidsearchname();

voidsearchwriter();

voidorderw(bbasicbinfo[100]);

voidorderw(bbasicbinfo[100]);

inthalfn(intsum,bbasicbinfo[100],char*find);

inthalfw(intsum,bbasicbinfo[100],char*find);

voidsta();

voidblist();

voidbmoney();

intmain(void)

{

menu();

}

voidmenu()

{

inty;

_window();/*显示窗口*/

words();/*显示菜单文字*/

y=choose(7,19);/*光标*/

play(y);/*根据键盘值操作*/

}

void_window()/*窗口初始化*/

{

textbackground(BLUE);

textcolor(WHITE);

clrscr();

box();

}

voidwords()/*显示菜单文字*/

{

textcolor(WHITE);

gotoxy(30,7);

textbackground(RED);

cprintf("AddBookinfo");

textbackground(BLUE);

gotoxy(30,10);

cprintf("ManageBook");

gotoxy(30,13);

cprintf("SearchBook");

gotoxy(30,16);

cprintf("BookStatistic");

gotoxy(30,19);

cprintf("Exit");

gotoxy(35,22);

textcolor(LIGHTGRAY);

textbackground(BLUE);

cprintf("MainMenu");

gotoxy(25,2);

textcolor(RED);

highvideo();

cprintf("TheLibraryManagemntProgram");

normvideo();

}

voidbox(intx,inty,inthigh,intwidth)/*画方框*/

{

inti;

gotoxy(x,y);

putchar(0xda);

for(i=1;i

{

putchar(0xc4);

}

putchar(0xbf);

gotoxy(x,y+high-3);

putchar(0xc0);

gotoxy(width,y+high-3);

putchar(0xd9);

for(i=1;i

{

gotoxy(x,y+i);

putchar(0xb3);

gotoxy(x+width-1,y+i);

putchar(0xb3);

}

gotoxy(x,y+high-1);

putchar(0xc0);

for(i=1;i

{

putchar(0xc4);

}

gotoxy(x+1,y+high-3);

for(i=1;i

{

putchar(0xc4);

}

gotoxy(x+width-1,y+high-1);

putchar(0xd9);

}

intkey()/*读键盘*/

{

unionREGSrg;

rg.h.ah=0;

int86(0x16,&rg,&rg);

returnrg.h.ah;

}

intchoose(intbot,inttop)/*根据Y的值选择操作*/

{

intky,y=7;

gotoxy(30,bot);

do

{

ky=key();

switch(ky)

{

caseKey_UP:

{

if(y>bot)

{

upbar(y);

y=y-3;

}

};break;

caseKey_DOWN:

{

if(y

{

downbar(y);

y=y+3;

}

};break;

}

}

while(ky!

=Key_ENTER);

returny;

}

upbar(inty)/*光标上移*/

{

inti;

typedefstructtexel_struct

{

unsignedcharch;

unsignedcharattr;

}texel;

texelt;

for(i=30;i<=48;i++)

{

gettext(i,y,i,y,&t);

t.attr=0x1f;

puttext(i,y,i,y,&t);

gettext(i,y-3,i,y-3,&t);

t.attr=0x4f;

puttext(i,y-3,i,y-3,&t);

};

gotoxy(30,y-3);

return;

}

downbar(inty)/*光标下移*/

{

inti;

typedefstructtexel_struct

{

unsignedcharch;

unsignedcharattr;

}texel;

texelt;

for(i=30;i<=48;i++)

{

gettext(i,y,i,y,&t);

t.attr=0x1f;

puttext(i,y,i,y,&t);

gettext(i,y+3,i,y+3,&t);

t.attr=0x4f;

puttext(i,y+3,i,y+3,&t);

};

gotoxy(30,y+3);

return;

}

voidplay(inty)/*根据y的值选择操作*/

{

switch(y)

{

case7:

add();

break;

case10:

manage();

break;

case13:

search();

break;

case16:

sta();

break;

case19:

exit

(1);

default:

printf("Error");exit(0);

}

}

voidadd()/*显示"选择增加那种类型的信息"的窗口*/

{

inty;

_window();

gotoxy(30,7);

textbackground(RED);

cprintf("AddBasicinfo");

textbackground(BLUE);

gotoxy(30,10);

cprintf("AddPurchaseinfo");

gotoxy(30,13);

cprintf("AddBorrowinfo");

gotoxy(30,16);

cprintf("Back");

gotoxy(25,2);

textcolor(RED);

highvideo();

cprintf("TheLibraryManagemntProgram");

normvideo();

gotoxy(35,22);

textcolor(LIGHTGRAY);

textbackground(BLUE);

cprintf("AddBook");

textbackground(BLUE);

textcolor(WHITE);

y=choose(7,16);

switch(y)/*选择增加信息类型的函数*/

{

case7:

addbook();break;/*增加图书基本信息*/

case10:

addbuy();break;/*增加图书购买信息*/

case13:

addborrow();break;/*增加图书借阅信息*/

case16:

menu();break;

default:

printf("Error");break;

}

}

voidaddbook()/*增加图书基本信息*/

{

intky,sum=0;

FILE*fp;

bbasicbinfo;

textbackground(BLUE);

textcolor(WHITE);

clrscr();

if((fp=fopen("e:

\\sum.dat","rb"))!

=NULL)/*读取图书基本信息数量sum*/

{

fread(&sum,2,1,fp);

}

fclose(fp);

if((fp=fopen("e:

\\addbook.dat","ab"))==NULL)

{

printf("cannotwritetheaddbook.dat");

}

do

{

clrscr();

gotoxy(2,2);

cprintf("Pleaseinputtheclassficationofchineselibraryclassification:

");

scanf("%s",&binfo.type);

getchar();

gotoxy(2,4);

cprintf("Pleaseinputthebook'snumber:

");

scanf("%s",&binfo.num);

getchar();

gotoxy(2,6);

cprintf("Pleaseinputthebook'sname:

");

scanf("%s",&binfo.name);

getchar();

gotoxy(2,8);

cprintf("Pleaseinputthebook'swriter:

");

scanf("%s",&binfo.writer);

getchar();

gotoxy(2,10);

cprintf("Pleaseinputthethebook'spress:

");

scanf("%s",&binfo.press);

getchar();

gotoxy(2,12);

cprintf("Pleaseinputthebook'sedition:

");

scanf("%s",&binfo.edition);

getchar();

gotoxy(2,14);

cprintf("Pleaseinputthebook'spublishtime:

");

scanf("%s",&binfo.time);

getchar();

gotoxy(2,16);

cprintf("Pleaseinputtheprice:

");

scanf("%f",&binfo.price);

getchar();

gotoxy(2,18);

cprintf("PleaseinputtheISBNofthebook:

");

scanf("%s",&binfo.ISBN);

getchar();

gotoxy(2,20);

cprintf("Pleaseinputthecountofbooks:

");

scanf("%d",&binfo.count);

getchar();

gotoxy(2,22);

cprintf("Pleaseinputthelendnumberofthebook:

");

scanf("%d",&binfo.lendnum);

getchar();

gotoxy(10,25);

cprintf("PressN(n)tofinishaddbookorPressanykeytoaddmorebook.");

ky=key();

sum++;

if(fwrite(&binfo,sizeof(bbasic),1,fp)!

=1)

{

clrscr();

printf("cannotsavethedata.");

}

}while(ky!

=Key_N);

fclose(fp);

if((fp=fopen("e:

\\sum.dat","wb"))==NULL)

{

printf("cannotsavethesumofthebook.");

getch();

exit(0);

}

if(fwrite(&sum,2,1,fp)!

=1)

{

printf("failtowritethesum.dat.");

getch();

exit(0);

};

fclose(fp);

menu();

}

/*中图法分类号、(要考虑多个作者情况)、出版社、出版日期、ISBN、版次、定价、馆藏数、借阅数等。

*/

voidaddbuy()/*增加图书购买信息*/

{

intky;

FILE*fp;

bpurchasepinfo;

textbackground(BLUE);

textcolor(WHITE);

clrscr();

if((fp=fopen("e:

\\addbuy.dat","ab"))==NULL)

{

printf("cannotopentheaddbuydata.");

exit(0);

}

do

{

clrscr();

gotoxy(2,2);

cprintf("Pleaseinputthebook'sname:

");

scanf("%s",&pinfo.name);

gotoxy(2,4);

cprintf("Pleaseinputthebook'swriter:

");

scanf("%s",&pinfo.writer);

gotoxy(2,6);

cprintf("Pleaseinputthebook'sbuytime:

");

scanf("%s",&pinfo.writer);

gotoxy(2,8);

cprintf("Pleaseinputthenumberofthebookbuy:

");

scanf("%d",&pinfo.num);

gotoxy(2,10);

cprintf("Pleaseinputtheprice:

");

scanf("%f",&pinfo.price);

gotoxy(2,12);

cprintf("Pleaseinputtherealmoneyofbuythebook:

");

scanf("%f",&pinfo.money);

gotoxy(2,14);

cprintf("Pleaseinputthebillnumber:

");

scanf("%s",&pinfo.bill);

gotoxy(10,20);

cprintf("PressN(n)tofinishaddbookorPressanykeytoaddmorebook.");

ky=key();

if(fwrite(&pinfo,sizeof(pinfo),1,fp)!

=1)

{

clrscr();

printf("cannotsavethedata.");

}

}while(ky!

=Key_N);

fclose(fp);

menu();

}

voidaddborrow()/*增加图书借阅信息*/

{

intky;

FILE*fp;

blendlinfo;

textbackground(BLUE);

textcolor(WHITE);

clrscr();

if((fp=fopen("e:

\\addborrow.dat","ab"))==NULL)

{

printf("cannotopentheaddborrowdat

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

当前位置:首页 > 经管营销

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

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