图书管理系统源代码原创Word文档下载推荐.docx

上传人:b****3 文档编号:16969626 上传时间:2022-11-27 格式:DOCX 页数:38 大小:20.46KB
下载 相关 举报
图书管理系统源代码原创Word文档下载推荐.docx_第1页
第1页 / 共38页
图书管理系统源代码原创Word文档下载推荐.docx_第2页
第2页 / 共38页
图书管理系统源代码原创Word文档下载推荐.docx_第3页
第3页 / 共38页
图书管理系统源代码原创Word文档下载推荐.docx_第4页
第4页 / 共38页
图书管理系统源代码原创Word文档下载推荐.docx_第5页
第5页 / 共38页
点击查看更多>>
下载资源
资源描述

图书管理系统源代码原创Word文档下载推荐.docx

《图书管理系统源代码原创Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《图书管理系统源代码原创Word文档下载推荐.docx(38页珍藏版)》请在冰豆网上搜索。

图书管理系统源代码原创Word文档下载推荐.docx

voidtime_chaxun(structbook*head);

//按出版时间查询图书

voidbname_chaxun(structbook*head);

//按图书名查询图书

voidxiugai(structbook*head);

//修改图书信息

voidpaixu(structbook*head);

//对图书进行排序

voidnum_paixu(structbook*head);

//按图书编号排序

voidtime_paixu(structbook*head);

//按图书出版时间排序

voidprice_paixu(structbook*head);

//按图书价格排序

voidbname_paixu(structbook*head);

//按图书名排序

voidwname_paixu(structbook*head);

//按作者名排序

intmain()

{

intchoice,n,x,y=1,c,c1=1;

chara,d,b[10],b1[10]="

1"

;

structbook*head=NULL;

while(y){

system("

cls"

);

printf("

\n\n\n\n\n"

----------------------------------------------------------------------\n"

---||-------------||-------图书信息管理系统--------||-----------||---\n"

---||-------------||-------登陆界面--------||-----------||---\n"

printf("

\n"

============1-进入系统===========\n"

============0-退出系统===========\n"

请输入选择:

"

scanf("

%d"

&

n);

getchar();

switch(n){

case0:

y=0;

break;

case1:

请输入您的用户名(输入1即可):

gets(b);

请输入您的密码(输入1即可):

scanf("

c);

if(strcmp(b,b1)!

=0||c!

=c1){

验证失败,请重新输入!

%c"

d);

getchar();

system("

}

else{

验证通过!

请按Enter键进入!

x=1;

while(x){

system("

color1F"

----------------------------------------------------------------------\n\n"

---||-------------||-------图书信息管理系统--------||-----------||---\n\n"

---||-------------||-----------操作界面------------||-----------||---\n\n"

printf("

----------------------------------------------\n"

----||-----------系统菜单选项-----------||----\n"

-||1-添加图书删除图书-2||-\n\n"

-||3-图书列表图书排序-4||-\n\n"

-||5-查询图书修改图书-6||-\n\n"

-||7-录入数据退出系统-0||-\n\n"

----------------------------------------------\n\n"

请输入所选择的序号:

choice);

switch(choice)

{

case0:

x=0;

break;

head=load();

if(head==NULL){

文件为空,请先录入数据!

getchar();

break;

}

else{

head=addbook(head);

添加成功!

是否将新信息保存到文件?

(y/n)\n"

a);

switch(a){

case'

n'

:

break;

y'

fprint(head);

printf("

保存成功!

getchar();

}

case2:

if(head==NULL){

deletebook(head);

}

case3:

head=load();

print_book(head);

case4:

paixu(head);

case5:

else{

chaxun(head);

case6:

xiugai(head);

break;

case7:

printf("

注意:

输入图书编码为0时结束!

head=creatbook();

是否将输入的信息保存到文件以覆盖文件中已存在的信息?

scanf("

switch(a){

case'

0'

default:

输入有误,请重新输入!

getchar();

}

break;

输入有误,请重新输入!

}

}

//录入数据并形成链表

structbook*creatbook()

structbook*head,*tail,*p;

intnum,time,n;

charbname[50],wname[20],press[50],sort[50];

intsize=sizeof(structbook);

head=tail=NULL;

请输入图书编号:

num);

请输入图书名:

%s"

bname);

请输入作者名:

wname);

请输入出版社:

press);

请输入类别:

sort);

请输入出版时间:

time);

请输入价格:

%f"

price);

while

(1){

p=(structbook*)malloc(size);

p->

num=num;

strcpy(p->

bname,bname);

wname,wname);

press,press);

sort,sort);

time=time;

price=price;

next=NULL;

if(head==NULL)

head=p;

else

tail->

next=p;

tail=p;

do{

n=yanzheng(head,num);

if(n==0)

您输入的编号已存在,请重新输入!

}while

(1);

if(num==0)

{

scanf("

returnhead;

}

//插入结点,并且插入后仍按一定顺序

structbook*addbook(structbook*head)

structbook*ptr,*p1,*p2,*p;

intnum,time,n=1;

do{

p=(structbook*)malloc(size);

p->

strcpy(p->

p2=head;

ptr=p;

while((ptr->

num>

p2->

num)&

&

(p2->

next!

=NULL)){

p1=p2;

p2=p2->

next;

if(ptr->

num<

=p2->

num){

if(head==p2)

head=ptr;

p1->

next=ptr;

next=p2;

else{

p2->

//验证添加的图书编号是否已存在

intyanzheng(structbook*head,intm)

structbook*p;

p=head;

while(p!

=NULL){

if(p->

num==m)

p=p->

if(p==NULL)

return0;

else

return1;

//将新链表写入文件中

voidfprint(structbook*head)

FILE*fp;

charch='

1'

structbook*p1;

if((fp=fopen("

f1.txt"

"

w"

))==NULL){

Fileopenerror!

exit(0);

fputc(ch,fp);

for(p1=head;

p1;

p1=p1->

next){

fprintf(fp,"

%d%s%s%s%s%d%f\n"

p1->

num,p1->

bname,p1->

wname,p1->

press,p1->

sort,p1->

time,p1->

fclose(fp);

//从文件中读取图书信息

structbook*load()

charch;

structbook*head,*tail,*p1;

r"

ch=fgetc(fp);

if(ch=='

){

while(!

feof(fp)){

p1=(structbook*)malloc(sizeof(structbook));

fscanf(fp,"

%d%s%s%s%s%d%f\n"

p1->

sort,&

time,&

head=p1;

next=p1;

tail=p1;

tail->

returnNULL;

//将整个链表的信息输出

voidprint_book(structbook*head)

structbook*ptr;

\n没有信息!

return;

图书信息列表如下\n"

============================================================================\n"

编号图书名作者名出版社类别出版时间价格\n"

for(ptr=head;

ptr;

ptr=ptr->

next)

%3d%-12s%-8s%-14s%-2s%-4d%.2f\n"

ptr->

num,ptr->

bname,ptr->

wname,ptr->

press,ptr->

sort,ptr->

time,ptr->

//删除图书信息

voiddeletebook(structbook*head)

inta;

charb,ch='

structbook*p1,*p2;

请输入要删除的图书编号:

p1=head;

if(p1->

num==a&

next==NULL){//对于文件中只有一组数据

是否清空文件!

b);

switch(b){

case'

文件已清空!

while(p1->

num!

=a&

p2=p1;

p1=p1->

next==NULL){

num==a){

是否确定从文件中彻底删除该图书?

getchar(

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

当前位置:首页 > 小学教育 > 语文

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

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