C语言实现图书馆课程设计报告Word格式.docx

上传人:b****6 文档编号:17706375 上传时间:2022-12-08 格式:DOCX 页数:17 大小:19.92KB
下载 相关 举报
C语言实现图书馆课程设计报告Word格式.docx_第1页
第1页 / 共17页
C语言实现图书馆课程设计报告Word格式.docx_第2页
第2页 / 共17页
C语言实现图书馆课程设计报告Word格式.docx_第3页
第3页 / 共17页
C语言实现图书馆课程设计报告Word格式.docx_第4页
第4页 / 共17页
C语言实现图书馆课程设计报告Word格式.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

C语言实现图书馆课程设计报告Word格式.docx

《C语言实现图书馆课程设计报告Word格式.docx》由会员分享,可在线阅读,更多相关《C语言实现图书馆课程设计报告Word格式.docx(17页珍藏版)》请在冰豆网上搜索。

C语言实现图书馆课程设计报告Word格式.docx

12345678C语言程序设计清华大学38.00y

借阅信息:

学号图书编号借阅日期还书日期逾期罚款

1001123456782007/9/102007/10/10…

功能要求如下:

1、增加图书信息

2、增加学生信息

3、借、还书登记

4、计算逾期罚款金额,按0.1元/天计算。

5、对数据可以进行增、删、改的编辑操作。

6、对数据可进行查询操作。

7、逾期罚款单

二、系统设计方案

可以实现图书信息的登记,以及增、删、改,可以对图书进行多方面操作。

实现对学生的借书登记等功能。

定义了三个结构体,分别是图书信息,学生信息和日期结构体。

其中调用了11个自定义函数,运用菜单函数实现函数的连接,切换。

整个系统,多用了数组进行实现。

三、程序主要代码分析

//头文件

#include<

stdio.h>

stdlib.h>

string.h>

conio.h>

//全局变量

inta=0;

intb=0;

intc=0;

//结构体

structbookinfo

{

charnum[10];

charname[20];

charpublish[50];

floatprice;

}book[100],abook;

//图书

structstudentinfo

charnumber[10];

charmajor[50];

}student[100];

//学生

structlendinfo

charstunum[10];

charbooknum[10];

intyear;

intmonth;

intday;

}lend[100];

//借阅信息

//函数说明

voidputin(structbookinfobook[]);

//图书信息录入

voidputout(structbookinfobook[]);

//图书信息显示

voidmenu();

//菜单

voidputinstudent(structstudentinfostudent[]);

//学生信息录入

voidputoutstudent(structstudentinfostudent[]);

//学生信息显示

voidaddbook(structbookinfobook[]);

//增加图书信息

voidaddstudent(structstudentinfostudent[]);

//增加学生信息

voidsearchbook(structbookinfobook[]);

//查询想要图书

voidlendinfo(structlendinfoleng[]);

//借阅信息输入

voidputlendinfo(structlendinfolend[]);

//借阅信息查询

voidalterbook(structbookinfobook[]);

//修改图书信息

voiddelbook(structbookinfobook[]);

//删除图书信息

//主函数

voidmain()

menu();

}

voidmenu()

//structbookinfo;

intk;

system("

cls"

);

printf("

\n\n\n\n\n\t\t\t\t图书信息管理系统\t\t\t\t\n"

\t\t*********************************************\n"

\t\t\t1------------------图书信息录入\n"

\t\t\t2------------------图书信息显示\n"

\t\t\t3------------------增加图书信息\n"

\t\t\t4------------------修改图书信息\n"

\t\t\t5------------------删除图书信息\n"

\t\t\t6------------------查询图书信息\n"

\t\t\t7------------------学生信息录入\n"

\t\t\t8------------------学生信息显示\n"

\t\t\t9------------------增加学生信息\n"

\t\t\t10------------------输入借阅信息\n"

printf("

\t\t\t11------------------借阅信息查询\n"

\t\t\t0------------------退出系统\n"

\t\t请输入对应编号进入对应系统\n"

fflush(stdin);

scanf("

%d"

&

k);

switch(k)

{

case1:

putin(book);

break;

case2:

putout(book);

case3:

addbook(book);

case4:

alterbook(book);

case5:

delbook(book);

case6:

searchbook(book);

case7:

putinstudent(student);

case8:

putoutstudent(student);

case9:

addstudent(student);

case10:

lendinfo(lend);

case11:

putlendinfo(lend);

case0:

exit

(1);

default:

printf("

\n序号不对\n"

}

//1.图书信息录入

voidputin(structbookinfobook[])

intk=1;

while(k!

=0)

请输入图书编号:

\n"

%s"

book[a].num);

请输入书名:

book[a].name);

请输入出版社:

book[a].publish);

请输入单价:

%f"

book[a].price);

a++;

\n是否继续录入(1.继续;

0,退出录入):

"

fflush(stdin);

if(k!

=1)

menu();

}

//2.图书信息显示

voidputout(structbookinfobook[])

inti,k;

编号\t书名\t出版社\t单价\n"

for(i=0;

i<

a;

i++)

%s\t%s\t%s\t%f\n"

book[i].num,book[i].name,book[i].publish,book[i].price);

输入0退出系统,输入其他返回菜单\n"

scanf("

if(k!

menu();

//3.学生信息录入

voidputinstudent(structstudentinfostudent[])

请输入学号:

student[b].number);

请输入姓名:

student[b].name);

请输入院系:

student[b].major);

b++;

//4.学生信息输出

voidputoutstudent(structstudentinfostudent[])

学号\t姓名\t院系\n"

b;

%s\t%s\t%s\t\n"

student[i].number,student[i].name,student[i].major);

//5.增加图书信息

voidaddbook(structbookinfobook[])

请输入增加的图书编号:

请输入增加的图书的书名:

请输入增加的图书的出版社:

请输入增加的图书的单价:

//6.增加学生信息

voidaddstudent(structstudentinfostudent[])

请输入增加学生的学号:

请输入增加学生的姓名:

请输入增加学生的院系:

//7.查询想要图书

voidsearchbook(structbookinfobook[])

chars2[100];

intk=1,m=1;

\n请输入要查询的书名:

"

s2);

for(inti=0;

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

\n\n\n编号\t书名\t出版社\t单价\n"

k=0;

%s\t%s\t%s\t%f\n\n\n"

\n\n\n你想要的图书不存在!

\n\n\n\n"

m);

if(m!

//8.借阅信息输入

voidlendinfo(structlendinfoleng[])

lend[c].stunum);

lend[c].booknum);

请输入借阅年:

lend[c].year);

请输入借阅月(1--12):

lend[c].month);

请输入借阅日(1--31):

lend[c].day);

c++;

//9.借阅信息查询

voidputlendinfo(structlendinfolend[])

学号\t图书编号\t借阅日期\t应还日期\n"

c;

if(lend[i].month==12)

printf("

%s\t%s\t\t%d.%d.%d\t%d.%d.%d\n"

lend[i].stunum,lend[i].booknum,lend[i].year,lend[i].month,lend[i].day,lend[i].year+1,1,lend[i].day);

else

lend[i].stunum,lend[i].booknum,lend[i].year,lend[i].month,lend[i].day,lend[i].year,lend[i].month+1,lend[i].day);

//10.修改图书信息

voidalterbook(structbookinfobook[])

charalter[20];

请输入你想修改图书编号:

alter);

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

{

break;

if(i!

=a)

请输入修改后图书编号:

abook.num);

请输入修改后书名:

abook.name);

请输入修改后出版社:

abook.publish);

请输入修改后单价:

abook.price);

strcpy(book[i].name,abook.name);

strcpy(book[i].num,abook.num);

strcpy(book[i].publish,abook.publish);

book[i].price=abook.price;

else

\n\n\n对不起,找不到书!

//11.删除图书信息

voiddelbook(structbookinfobook[])

chardel[20];

请输入你想删除的图书编号:

del);

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

break;

for(;

a-1;

strcpy(book[i].name,book[i+1].name);

strcpy(book[i].num,book[i+1].num);

strcpy(book[i].publish,book[i+1].publish);

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

a--;

\t\n删除成功!

\n\n\n"

四、程序调试中出现的问题及其解决方法

1、刚开始编这套程序时,无法进行各功能之间的切换,就是说,进入某一功能后,无法退回主菜单,继续完成其他的功能操作。

经过老师的点拨后,发现可以把主函数里的函数全部省略,然后定义一个菜单函数,把菜单函数写入主函数,然后其他各个函数可以通过逻辑,如果不成立则返回主菜单,结果真的成功了。

2、编译调试时,发现实现每个功能后,无法把已使用过的功能清除,这个严重影响了函数的美观,使用后会觉得很凌乱,无法实现人性化。

但是经过查阅资料后,发现可以建立一个#include<

头文件,然后使用system("

进行清屏。

感觉这个函数十分实用,用了之后,明显感觉整个函数的使用都变清楚了。

3、编写删除图书信息这个功能时,我的逻辑是:

先找到删除的书,然后把之后的图书信息提前一个位置。

但是当我编译时发现,每次删除一个图书,总是最后一个图书信息留着两个,当时感觉很疑惑。

但是经过和同学的讨论发现,删完之后,宏定义a必须减一,不然最后一个图书信息还会留着。

4、编写借书函数时,我发现,日期是个很难的操作,当我们借书是12月时,年份会加一,当时没想到怎么编译,但是经过查阅信息后发现,我可以假想了每个月是30天,这样编译会更加简单。

5、编写查询图书信息的功能时,我无法想到怎样让一个数组等于我想查找的数组,但是询问老师后发现,原来我们学过这个功能,只需要定义一个#include<

头文件,然后用strcmp(s2,book[i].name)==0来进行实现这个功能。

五、改进意见与收获体会

当我编译完这个系统时,我感到其实还是有很多缺陷,比如说,计算还书年份日期时,我只能假想到每月是30天,其实这个是不科学的,现实生活中的日期是分30,31天的,并且还有闰年2月有29天这种情况,总的来说还是不完善的系统,但是现在我想到了用switch函数来实现,其实也是很简单的,不要用break,可以很明显的发现,妙用这种情况是可以很简单的计算日期的,不管是不是闰年。

如果这个函数加进去的话,我觉得就比较好了,这个是我的改进意见。

说到收获和体会,我真的是感慨万千,第一,我发现了自己的不足和见识的浅陋,每次老师都能很准确的发现到我的问题,但是我却到不到这种境界,看来真的是学无止境啊,我还年轻,要学的东西还很多。

第二,我深深体会到了c语言的变化万千和博大精深,有的时候仅仅是一点变化,有时会发现编译不出来,有时会发现,编译出来的东西和自己想象中的情况相差很大,我们还需要更加深刻的去了解c语言,了解它的精妙之处。

第三,我体会到了成功的喜悦感和充实感,看到自己辛辛苦苦编译了500多行的程序大功告成时,心中充满了一种兴奋,这么多行的程序在外人看来肯定会觉得很牛吧,哈哈。

第四,我学会了一种不畏困难的精神,回想到当时老师给我们这个要求时,心中充满了不满和痛苦,感觉凭借自己学的东西,根本编译不出这么复杂的

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

当前位置:首页 > 高中教育 > 其它课程

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

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