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

上传人:b****4 文档编号:6740736 上传时间:2023-05-10 格式:DOCX 页数:33 大小:23.42KB
下载 相关 举报
c语言 图书管理系统 上机实验报告.docx_第1页
第1页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第2页
第2页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第3页
第3页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第4页
第4页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第5页
第5页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第6页
第6页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第7页
第7页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第8页
第8页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第9页
第9页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第10页
第10页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第11页
第11页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第12页
第12页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第13页
第13页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第14页
第14页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第15页
第15页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第16页
第16页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第17页
第17页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第18页
第18页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第19页
第19页 / 共33页
c语言 图书管理系统 上机实验报告.docx_第20页
第20页 / 共33页
亲,该文档总共33页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

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

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

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

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]);

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

int(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);

REGSrg;

rg.rg.y;

}

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);

("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("cannotopentheaddborrowdata.");

exit(0);

}

do

{

clrscr();

gotoxy(2,2);

cprintf("Pleaseinputthelendbook'sname:

");

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

gotoxy(2,4);

cprintf("Pleaseinputtheborrower'sname:

");

scanf("%s",&linfo.person);

gotoxy(2,6);

cprintf("Pleaseinputthecompanyoftheborrower:

");

scanf("%s",&linfopany);

gotoxy(2,8);

cprintf("Pleaseinputtheborrower'scard:

");

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

gotoxy(2,10);

cprintf("Pleaseinputtheborrowtime(ex.20100126):

");

scanf("%s",&linfo.btime);

gotoxy(2,12);

cprintf("Pleaseinputthereturntime(ex.20100508):

");

scanf("%s",&linfo.rtime);

gotoxy(10,20);

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

ky=key();

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

=1)

{

clrscr();

printf("cannotsavethedata.");

}

}while(ky!

=Key_N);

fclose(fp);

menu();

}

structlinklist*create()*创建链表*

{

inti,sum;

structlinklist*("e:

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

{

printf("cannotopenthefile.");

}

for(i=0;i

{

p2=p1;

p1=(structlinklist*)malloc(LEN);

p2->next=p1;

if(fread(&(p2->binfo),sizeof(bbasic),1,fp)!

=1)

{

printf("cannotsavethedata.");

}

}

p2->next=NULL;

fclose(fp);

returnofchineselibraryclassification:

");

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

getchar();

gotoxy(2,4);

cprintf("Pleaseinputthebook'snumber:

");

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

getchar();

gotoxy(2,6);

cprintf("Pleaseinputthebook'sname:

");

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

getchar();

gotoxy(2,8);

cprintf("Pleaseinputthebook'swriter:

");

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

getchar();

gotoxy(2,10);

cprintf("Pleaseinputthethebook'spress:

");

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

getchar();

gotoxy(2,12);

cprintf("Pleaseinputthebook'sedition:

");

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

getchar();

gotoxy(2,14);

cprintf("Pleaseinputthebook'spublishtime:

");

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

getchar();

gotoxy(2,16);

cprintf("Pleaseinputtheprice:

");

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

getchar();

gotoxy(2,18);

cprintf("PleaseinputtheISBNofthebook:

");

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

getchar();

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

当前位置:首页 > 工程科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2