小型图书信息管理系统(C语言)文档格式.doc
《小型图书信息管理系统(C语言)文档格式.doc》由会员分享,可在线阅读,更多相关《小型图书信息管理系统(C语言)文档格式.doc(10页珍藏版)》请在冰点文库上搜索。
voidinfor_input();
voidrefer();
voidrefer_1();
voidrefer_2();
voidmodify();
voiddelete();
voidfindbook();
voidfindbook1();
voidfindbook2();
voiddevise();
voidmain()
{
inta=0;
do
{
a=maininterface();
switch(a)
{
case1:
system("
CLS"
);
infor_input();
break;
case2:
refer();
case3:
modify();
case4:
delete();
case5:
exit(0);
default:
printf("
\n\n\n\n\t\t\t无此操作,请按任意键返回:
\n"
getch();
}
}while(a!
=6);
}
intmaininterface()
{
intn;
printf("
\n\n\n\t\t------------小型图书登记管理系统-----------\n"
\n\t\t\t\t1:
<
录入图书信息>
\n\t\t\t\t2:
查询信息>
\n\t\t\t\t3:
修改图书信息>
\n\t\t\t\t4:
删除图书信息>
\n\t\t\t\t5:
退出系统>
\n\t\t\t请输入1--5,其他输入非法!
scanf("
%d"
&
n);
returnn;
}
typedefstruct
intmonth;
intday;
intyear;
}DATES;
DATESday;
typedefstructbooks
{
charbookname[50];
charISBN[50];
charauthor[50];
charpublisher[50];
floatmoney;
DATESday;
intcount;
structbooks*next;
}BOOK_TYPE;
BOOK_TYPEts;
structbooks*head=NULL;
voidinfor_input()
FILE*fp;
intn=0;
BOOK_TYPEts;
printf("
---------------图书资料基本信息录入--------------\n"
printf("
请输入书名\n"
scanf("
%s"
ts.bookname);
请输入ISBN\n"
scanf("
ts.ISBN);
请输入作者\n"
ts.author);
printf("
请输入出版社\n"
ts.publisher);
请输入定价\n"
%f"
ts.money);
请输入出版日期\n"
%d/%d/%d"
ts.day.month,&
ts.day.day,&
ts.day.year);
请输入数量\n"
ts.count);
\n\t\t\t请选择(1:
确定\t2:
取消\t0:
重新输入):
"
}while(n==0);
if(n==1)
if((fp=fopen("
book.txt"
"
a"
))==NULL)/*若"
文件不存在,则以创建方式打开文件*/
fp=fopen("
w+"
}
fwrite(&
ts,LL,1,fp);
/*将输入的图书信息写入磁盘文件"
*/
fclose(fp);
}
system("
输入成功!
请选择(1:
返回主界面\t2:
输入另一本图书信息\t0:
退出系统):
switch(n)
{
case1:
case2:
case0:
default:
无此操作,按任意键返回\n"
voidrefer()
printf("
1:
根据ISBN号,找出图书信息>
2:
根据出版社名称,找出所有图书信息>
3:
根据书名,找出图书信息>
4:
统计书籍总数>
5:
统计书籍总金额和平均价格>
0:
返回>
请输入0--5,其他输入非法!
scanf("
switch(n)
{
findbook();
findbook1();
case3:
findbook2();
case4:
refer_1();
case5:
refer_2();
无此操作\n"
}
structbooks*read_1()
structbooks*p1,*p2,*head;
fp=fopen("
r"
head=p1=(BOOK_TYPE*)malloc(LL);
fread(p1,LL,1,fp);
while(feof(fp)==0)
p2=(BOOK_TYPE*)malloc(LL);
fread(p2,LL,1,fp);
p1->
next=p2;
p1=p2;
p1->
next=NULL;
fclose(fp);
returnhead;
voidrefer_1()
structbooks*head,*p,*d;
structbooks*read_1();
inttotal=0;
head=read_1();
for(p=head;
p->
next!
=NULL;
d=p,p=p->
next,free(d))
total=total+p->
count;
书籍总数:
%d\n"
total);
按任意键返回"
voidrefer_2()
{
intnum=0;
structbooks*head,*p1,*p2;
structbooks*read_1();
floattotal=0,average=0;
head=read_1();
for(p1=head;
p1->
p2=p1,p1=p1->
next,free(p2))
{
num=num+p1->
total=total+p1->
money*p1->
}
average=total/num;
书籍总金额:
%.2f\n"
书籍平均价格:
average);
voidfindbook()
inti;
请输入书的ISBN号\n"
ISBN);
for(i=0;
fread(&
ts,LL,1,fp)!
=0;
i++)
if(strcmp(ISBN,ts.ISBN)==0)
这本书的详细资料为:
%s%s%s%s%f%d/%d/%d%d\n按任意键返回\n"
ts.bookname,ts.ISBN,ts.author,ts.publisher,ts.money,ts.day.month,ts.day.day,ts.day.year,ts.count);
没有你所需要的书籍"
voidfindbook1()
charpublisher[50];
请输入书的publisher\n"
publisher);
if(strcmp(publisher,ts.publisher)==0)
voidfindbook2()
请输入书的bookname\n"
bookname);
if(strcmp(bookname,ts.bookname)==0)
voiddelete()
structbooks*p1,*p2;
charISBN[50];
inte=0;
if(head==NULL)
无书籍记录"
return;
}
请输入您要删除的书籍的ISBN:
scanf("
p1=head;
while(ISBN!
=p1->
ISBN&
&
p1->
next!
=NULL)
p2=p1;
p1=p1->
next;
if(ISBN==p1->
ISBN)
if(p1==head)
head=p1->
elsep2->
next=p1->
free(p1);
e--;
else
没有该书籍记录,请核对!
voidmodify()
无书籍记录!
请输入您要修改的书籍的ISBN\n:
devise(p1);
没有该学生记录,请核对!
voiddevise(structbooks*p)
intchoice;
choice=-1;
do
请选择您要修改的书籍的信息内容:
+----------------------+\n"
|书名请按1|\n"
|ISBN请按2|\n"
|作者请按3|\n"
|出版社请按4|\n"
|定价请按5|\n"
|出版日期请按6|\n"
|数量请按7|\n"
|取消请按0|\n"
请输入您的选择:
&
choice);
switch(choice)
case0:
case1:
请输入新书名:
p->
bookname);
case2:
请输入新ISBN:
ISBN);
case3:
请输入新作者:
author);
case4:
请输入新出版社:
publisher);
case5:
请输入新定价:
money);
case6:
请输入新出版日期:
%ld"
day.month,day.day,day.year);
case7:
请输入新数量:
count);
default:
\n无效选项!
while(choice!
=0);
经过一个多星期的C语言课程设计,感觉自己收获不少!
首先是:
链表本来上课是没有上的,但这个课程设计里面主要都是用链表,因为要达到这样的功能,使用链表相当方便,但不容易理解,所以在这方面我很了很多的时间看课本和参考课外书,使C语言的知识强化了不少。
其次,在做课程设计的过程中,发现了平时很多没有注意到的问题,例如:
返回值函数和不返回值函数两者在主函数中的调用是不同的…………
更重要的是,这次课程设计虽然花了我不少时间,但正是这些时间,让我见识到了C语言的重要性。
这个学生成绩管理系统都是在自己知识范围内完成的,所以界面清晰简单,可能不是很好看,但绝对实用!
从这里我也得到一个体会,做一个程序,或者开发一个软件,应该着重从它的后台制作入手,不能做出一个中看不中用的程序或者软件。
相信这次的课程设计为我以后继续从事计算机工作打了一个小小的开头。
由于这是第一次进行设计,写文档,难免会写得不好!