C语言图书系统代码Word文档格式.docx

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

C语言图书系统代码Word文档格式.docx

《C语言图书系统代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《C语言图书系统代码Word文档格式.docx(45页珍藏版)》请在冰点文库上搜索。

C语言图书系统代码Word文档格式.docx

voidsort_chaxun(structbook*head>

//按类别查询图书

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=1234。

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

yjk"

structbook*head=NULL。

while(y>

system("

cls"

>

printf("

\n\n\n\n\n\n\n"

**********欢迎光临**********\n\n"

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

printf("

\n\n"

============1-用户登录===========\n"

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

请输入您的选择:

"

scanf("

%d"

&

n>

\n"

getchar(>

switch(n>

case0:

y=0。

break。

case1:

请输入您的用户名:

gets(b>

请输入您的密码:

scanf("

c>

if(strcmp(b,b1>

!

=0||c!

=c1>

验证失败,请重新输入!

%c"

d>

getchar(>

system("

}

else{

验证通过!

请按Enter键进入!

x=1。

while(x>

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

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

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

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

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

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

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

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

请输入所选择的序号:

choice>

switch(choice>

{

case0:

x=0。

break。

head=load(>

if(head==NULL>

printf("

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

getchar(>

break。

}

else{

head=addbook(head>

添加成功!

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

(y/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'

default:

您的输入有误,请重新输入!

getchar(>

}

break。

您的输入有误!

请重新输入!

}

}

//录入数据并形成链表

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*ptr,*p1,*p2,*p。

intnum,time,n=1。

do{

p=(structbook*>

p->

strcpy(p->

p2=head。

ptr=p。

while((ptr->

p2->

&

(p2->

next!

=NULL>

p1=p2。

p2=p2->

next。

if(ptr->

num<

=p2->

if(head==p2>

head=ptr。

p1->

next=ptr。

next=p2。

else{

p2->

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

structbook*p。

p=head。

while(p!

if(p->

num==m>

p=p->

if(p==NULL>

return0。

else

return1。

//将新链表写入文件中

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>

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

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。

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

structbook*ptr。

\n没有信息!

return。

图书信息列表如下\n"

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

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

for(ptr=head。

ptr。

ptr=ptr->

%d%s%s%s%s%d%.2f\n"

ptr->

num,ptr->

bname,ptr->

wname,ptr->

press,ptr->

sort,ptr->

time,ptr->

//删除图书信息

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

num==a>

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

switch(b>

case'

fprint(head>

删除成功!

没有找到要删除的数据!

elseif(p1==head>

head=p1->

next=p1->

//图书查询

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

当前位置:首页 > 初中教育 > 语文

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

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