图书信息管理系统设计Word格式.docx
《图书信息管理系统设计Word格式.docx》由会员分享,可在线阅读,更多相关《图书信息管理系统设计Word格式.docx(8页珍藏版)》请在冰豆网上搜索。
stdio.h>
#include<
string.h>
stdlib.h>
#defineN10
structlibrary
{
intnum;
charbook_name[30];
charwriter[30];
charsort_num[3];
charpub_company[30];
charpub_time[30];
charprise[30];
};
typedefstructlibraryLIB;
LIBlib[N];
FILE*fp;
intall=0;
intmenu(void);
voidinput(void);
voidoutput(void);
voidsave(void);
voiddel(void);
voidsearch(void);
voidxiugai(void);
/*voidsort(void);
*/main()
for(;
;
)
switch(menu())
case1:
input();
break;
case2:
utput();
case3:
save();
case4:
search();
case5:
xiugai();
case6:
del();
/*case7:
sort();
*/
case0:
exit
(1);
}
intmenu(void)
charm[3];
intn;
printf("
\t\t1:
input\n"
);
printf("
\t\t2:
utput\n"
\t\t3:
save\n"
\t\t4:
search\n"
\t\t5:
xiugai\n"
\t\t6:
del\n"
\t\t7:
sort\n"
\t\t0:
exit\n"
\t\tpleasechooseaoperation(0-6):
\n"
scanf("
%s"
m);
n=atoi(m);
return(n);
voidinput(void)
inti;
for(i=all;
i<
N;
i++)
all++;
pleaseinputinformations:
\t\tnum:
%d"
&
lib.num);
\t\tbook_name:
lib.book_name);
\t\twriter:
lib.writer);
\t\tsort_num:
lib.sort_num);
\t\tpub_company:
lib.pub_company);
\t\tpub_time:
lib.pub_time);
\t\tprise:
lib.prise);
a:
\t\tyes/nocontinueinput?
yes\n"
no\n"
if(atoi(m)==1)
continue;
elseif(atoi(m)==2)
return;
else
\t\tinputerror!
gotoa;
voidoutput(void)
for(i=0;
all;
\t\t%d\n"
lib.num);
%s\t\t%s\t\t%s\n"
lib.book_name,lib.writer,lib.sort_num);
lib.pub_company,lib.pub_time,lib.prise);
voidsave(void)
if((fp=fopen("
file.c"
"
wb"
))==NULL){
cannotopenthefile"
exit
(1);
if(fwrite(&
lib,sizeof(LIB),1,fp)!
=1){
cannotwrite!
"
fclose(fp);
voidsearch(void)
inti,flag;
charname[30];
\t\tpleasechooseyourwayofsearch:
bybook_name!
bywriter!
scanf("
i=atoi(m);
switch(i)
\t\tpleaseinputthebook_name:
name);
flag=0;
if(strcmp(name,lib.book_name)==0)
flag=1;
if(flag==0)
\t\tnotfindthebook!
\t\tpleaseinputthewriter:
if(strcmp(name,lib.writer)==0)
\t\tnotfindthewtiter!
voidxiugai(void)
charname[30],n[3];
\t\tpleaseinputthebook_nameofxiugai:
\t\tpleaseinputxiugai'
stheinformations:
\t\tnotfindxiugai'
sthebook!
voiddel(void)
inti,j,flag;
\t\tpleaseinputthebook_nameofdel:
for(j=N;
j>
i;
j--)
lib[j-1].num=lib[j].num;
strcpy(lib[j-1].book_name,lib[j].book_name);
strcpy(lib[j-1].writer,lib[j].writer);
strcpy(lib[j-1].sort_num,lib[j].sort_num);
strcpy(lib[j-1].pub_company,lib[j].pub_company);
strcpy(lib[j-1].pub_time,lib[j].pub_time);
strcpy(lib[j-1].prise,lib[j].prise);
\t\tdelok!
\t\tnoinformationofthebook!
}
运行结果