C语言图书标准管理系统源代码_第1页
C语言图书标准管理系统源代码_第2页
C语言图书标准管理系统源代码_第3页
C语言图书标准管理系统源代码_第4页
C语言图书标准管理系统源代码_第5页
已阅读5页,还剩62页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

/*需要在源代码相同目录下创建四个txt文件:tushu_list.txt,jieshu_list.txt,xuesheng_list.txt,guanliyuan.txt*/#include<stdio.h>#include<stdlib.h>#include<string.h>structtushu{/*图书结构体*/ charnum[11];/*编号*/ charname[31];/*书名*/ charwriter[21];/*作者*/ charpress[21];/*出版社*/ charkind[21];/*类别*/ doubletime;/*时间*/ doubleprice;/*价格*/ structtushu*next;};structstu/*学生结构体*/{ intsnum;/*学号*/ charmima[11];/*密码*/structstu*next;};structjieshu{/*借书信息结构体*/ intxuehao; /*学生学号*/ charnum[11];/*编号*/ charname[31];/*书名*/ charwriter[21];/*作者*/ charpress[21];/*出版社*/ charkind[21];/*类别*/ doubletime;/*时间*/ doubleprice;/*价格*/ structjieshu*next;};intdenglu=-1; /*已登录学生学号*/FILE*fp; /*图书文件*/FILE*fp1; /*管理员信息文件*/FILE*fp2; /*学生信息文件*/FILE*fp3;/*借书信息文件*/intmain(); /*主函数申明*/structtushu*create(); /*从文件创建图书链表(从文件中读出图书信息,建立单链表)*/structstu*xcreate(); /*从文件创建学生信息(从文件读出学生信息,建立学生链表)*/structjieshu*jcreate(); //从文件创建借书信息链表structjieshu*borrowcreate(structtushu*k,structjieshu*h);//直接创建借书信息链表structtushu*Input(); /*图书添加(可进行图书添加)*/voidmenu(); /*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/voidxmenu(); /*学生主菜单(学生进入可对图书,密码进行操作)*/voidgfind(); /*管理员查询(管理员可按一定方法查询图书)*/voidxfind(); /*学生查询(学生可按一定方法查询图书)*/voidsecret(); /*管理员权限(管理员登陆所用,输入错误次数过多自动退出)*/voidsort(structtushu*head); /*排序(管理员可按一定方法对图书进行排序,排序完以后可选择文件进行保留)*/voidfprint(structtushu*head); /*保留(可追加保留,如添加可用)*/voidjsprint(structjieshu*h);//将借书信息添加到借书文件voidjfprint_(structtushu*head); /*借书保留(借书成功以后自动从图书馆删除)*/voidfprint_(structtushu*head); /*保留(可覆盖保留如修改,删除,排序后用)*/voidgBrowse(structtushu*head); /*管理员浏览(对图书进行遍历)*/voidxBrowse(structtushu*head); /*学生浏览(学生对图书进行遍历)*/voidcount(structtushu*head); /*统计数量(管理员可对图书进行统计)*/voidFindofname(structtushu*head); /*按书名查找*/voidFindofwriter(structtushu*head); /*按作者查找*/voidFindofkind(structtushu*head); /*按类别查找*/voidxFindofname(structtushu*head); /*学生按书名查找*/voidxFindofwriter(structtushu*head);/*学生按作者查找*/voidxFindofkind(structtushu*head); /*学生按类别查找*/voidSort_time(structtushu*head); /*按时间排序(管理员按时间对图书进行排序,排序完以后可选择文件进行保留)*/voidSort_price(structtushu*head); /*按价格排序*/voidSort_num(structtushu*head);/*按编号排序*/voidDelete(structtushu*head,charm[15]);/*按编号删除(管理员可按编号删除图书)*/voidRevise(structtushu*head); /*修改 (管理员可对图书进行修改,并选择是否保留)*/voidborrow(structtushu*head); /*借书*/voidhuanshu(structtushu*head); /*还书(学生借完书以后进行还书,若没有图书则不能借)*/voidgxinxi(); /*管理员信息(有管理员账号及密码,可进行修改)*/voidxmima(structstu*head1); /*学生密码修改(学生可对自己密码进行修改)*/voidxsecret(structstu*head1); /*学生权限(学生登陆所用)*/voidjsdelete(structjieshu*h); //学生还书时删除借书统计voidputin(jieshu*h);//将还书信息加入图书文件/*-------------------------------------------------------------------------------------------------------------------*/voidmenu()/*管理员主菜单(管理员进入对图书及学生信息进行管理操作)*/{ intchoice,n=0; structtushu*head; structstu*head1,*p; charm[15];there: printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf("┃┃图书管理系统┃┃\n"); printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf("┃●[0]退出系统┃\n"); printf("┃┃\n"); printf("┃●[1]返回主菜单┃\n"); printf("┃┃\n"); printf("┃●[2]浏览图书┃\n"); printf("┃┃\n"); printf("┃●[3]统计图书数目┃\n"); printf("┃┃\n"); printf("┃●[4]查询┃\n"); printf("┃┃\n"); printf("┃●[5]添加┃\n"); printf("┃┃\n"); printf("┃●[6]排序┃\n"); printf("┃┃\n"); printf("┃●[7]修改┃\n"); printf("┃┃\n"); printf("┃●[8]删除┃\n"); printf("┃┃\n"); printf("┃●[9]修改账号及密码┃\n"); printf("┃┃\n"); printf("┃●[10]学生信息┃\n"); printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf("请选择:"); fflush(stdin); head=create(); scanf("%d",&choice); if(choice==1) { system("cls"); printf("\n\n\n\t\t您已退出登录!\n\n\n\n"); system("pause"); main(); } elseif(choice==2) { system("cls"); if(head==NULL) { printf("没有图书,请先添加图书!\n"); system("pause"); system("cls"); menu(); } gBrowse(head); } elseif(choice==3) { system("cls"); count(head); } elseif(choice==4) { system("cls"); if(head==NULL) { printf("没有图书,请先添加图书!\n"); system("pause"); system("cls"); menu(); } gfind(); } elseif(choice==5) { Input(); } elseif(choice==6) { system("cls"); if(head==NULL) { printf("没有图书,请先添加图书!\n"); system("pause"); system("cls"); menu(); } sort(head); } elseif(choice==7) { system("cls"); if(head==NULL) { printf("没有图书,请先添加图书!\n"); system("pause"); system("cls"); menu(); } Revise(head); } elseif(choice==8) { if(head==NULL) { printf("没有图书,请先添加图书!\n"); system("pause"); system("cls"); menu(); } printf("请输入想要删除图书编号:"); scanf("%s",m); Delete(head,m); } elseif(choice==9) { gxinxi(); } elseif(choice==10) { system("cls"); head1=xcreate(); if(head1==NULL) { printf("没有学生信息,请到xuesheng_list.txt添加!\n"); system("pause"); system("cls"); menu(); } printf("学生学号密码\n"); for(p=head1;p!=NULL;p=p->next) { printf("%-10d%-10s\n",p->snum,p->mima); } system("pause"); system("cls"); menu(); } elseif(choice==0) { system("cls"); printf("\n\n\n\n"); printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n\n\n"); exit(0); } else { system("cls"); printf("\n\n\n\n━━━━输入错误,请重新输入!━━━━\n\n\n"); system("pause"); system("cls"); n++; if(n==3) { printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n"); printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n"); system("pause"); exit(0); } gotothere; }}//-----------------voidxmenu()/*学生主菜单(学生进入可对图书,密码进行操作)*/{ structtushu*head; structstu*head1; intchoice,n=0;there: printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf("┃┃图书借阅系统┃┃\n"); printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf("┃●[0]退出系统┃\n"); printf("┃┃\n"); printf("┃●[1]返回主菜单┃\n"); printf("┃┃\n"); printf("┃●[2]浏览图书┃\n"); printf("┃┃\n"); printf("┃●[3]查询┃\n"); printf("┃┃\n"); printf("┃●[4]借书┃\n"); printf("┃┃\n"); printf("┃●[5]还书┃\n"); printf("┃┃\n"); printf("┃●[6]修改密码┃\n"); printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf("请选择:"); fflush(stdin); head=create(); scanf("%d",&choice); if(choice==1) { denglu=-1; system("cls"); printf("\n\n\n\t\t您已退出登录!\n\n\n\n"); system("pause"); main(); } elseif(choice==2) { system("cls"); if(head==NULL) { printf("没有图书!\n"); system("pause"); system("cls"); xmenu(); } xBrowse(head); } elseif(choice==3) { if(head==NULL) { printf("没有图书!\n"); system("pause"); system("cls"); xmenu(); } xfind(); } elseif(choice==4) { if(head==NULL) { printf("没有图书!\n"); system("pause"); system("cls"); xmenu(); } borrow(head); } elseif(choice==5) { huanshu(head); } elseif(choice==6) { system("cls"); head1=xcreate(); if(head1==NULL) { printf("学生信息被清空!!\n"); system("pause"); system("cls"); xmenu(); } xmima(head1);; } elseif(choice==0) { system("cls"); printf("\n\n\n\n"); printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n"); exit(0); } else { system("cls"); printf("\n\n\n\n━━━━输入错误,请重新输入!━━━━\n\n\n"); system("pause"); system("cls"); n++; if(n==3) { printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n"); printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n"); system("pause"); exit(0); } gotothere; }}//--------------------voidgfind()/*管理员查询(管理员可按一定方法查询图书)*/{ intchoice,n=0; structtushu*head;there: system("cls"); printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf("┃┃图书借阅系统┃┃\n"); printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf("┃●[0]返回┃\n"); printf("┃┃\n"); printf("┃●[1]按书名查找┃\n"); printf("┃┃\n"); printf("┃●[2]按作者查找┃\n"); printf("┃┃\n"); printf("┃●[3]按类别查找┃\n"); printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf("请选择:"); fflush(stdin); head=create(); scanf("%d",&choice); if(choice==1) { system("cls"); Findofname(head); } elseif(choice==2) { system("cls"); Findofwriter(head); } elseif(choice==3) { system("cls"); Findofkind(head); } elseif(choice==0) { system("cls"); menu(); } else { system("cls"); printf("\n\n\n\n━━━━输入错误,请重新输入!━━━━\n\n\n"); system("pause"); system("cls"); n++; if(n==3) { printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n"); printf("━━━━━━━━感谢使用图书管理系统━━━━━━━━\n\n\n"); system("pause"); exit(0); } gotothere; }}//---------------------voidxfind()/*学生查询(学生可按一定方法查询图书)*/{ structtushu*head; intchoice,n=0;there: system("cls"); printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf("┃┃图书借阅系统┃┃\n"); printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n"); printf("┃●[0]返回┃\n"); printf("┃┃\n"); printf("┃●[1]按书名查找┃\n"); printf("┃┃\n"); printf("┃●[2]按作者查找┃\n"); printf("┃┃\n"); printf("┃●[3]按类别查找┃\n"); printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n"); printf("请选择:"); fflush(stdin); head=create(); scanf("%d",&choice); if(choice==1) { system("cls"); xFindofname(head); } elseif(choice==2) { system("cls"); xFindofwriter(head); } elseif(choice==3) { system("cls"); xFindofkind(head); } elseif(choice==0) { system("cls"); xmenu(); } else { system("cls"); printf("\n\n\n\n━━━━输入错误,请重新输入!━━━━\n\n\n"); system("pause"); system("cls"); n++; if(n==3) { printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n"); printf("━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n"); system("pause"); exit(0); } gotothere; }}//-------------------voidsort(structtushu*head){ structtushu*head2; intchoice,n=0;there: system("cls"); printf("┏━┓━━━━━━━━━━━━━━━━━━━┏━┓\n"); printf("┃┃图书借阅系统┃┃\n"); printf("┃┗━━━━━━━━━━━━━━━━━━━┛┃\n");printf("┃●[0]返回┃\n");printf("┃┃\n");printf("┃●[1]按时间排序┃\n");printf("┃┃\n");printf("┃●[2]按价格排序┃\n");printf("┃┃\n");printf("┃●[3]按编号排序┃\n");printf("┗━━━━━━━━━━━━━━━━━━━━━━━┛\n");printf("请选择:"); fflush(stdin); head2=create(); scanf("%d",&choice); if(choice==1) { system("cls"); Sort_time(head2); } elseif(choice==2) { system("cls"); Sort_price(head2); } elseif(choice==3) { system("cls"); Sort_num(head2); } elseif(choice==0) { system("cls"); menu(); } else { system("cls"); printf("\n\n\n\n━━━━输入错误,请重新输入!━━━━\n\n\n"); system("pause"); system("cls"); n++; if(n==3) { printf("\n\n\n━━━━━━━━你错误次数太多,自动退出!━━━━━━━━\n\n\n"); printf("━━━━━━━━感谢使用图书借阅系统━━━━━━━━\n\n\n");system("pause"); exit(0); } gotothere; }}//---------------------structtushu*Input(){ structtushu*p1,*p2,*head,*ptr; charnum; intx,i=0; system("cls"); p1=(structtushu*)malloc(sizeof(structtushu));head=p1; p1->price=-1; while(i!=1) { printf("请输入编号。若要结束图书信息录入,请输入'#'。\n"); scanf("%s",p1->num); if(strcmp(p1->num,"#")==0) i=1; while(i!=1) { printf("请依次输入书名作者出版社类别出版年份价格:\n"); scanf("%s%s%s%s%lf%lf",p1->name,p1->writer,p1->press,p1->kind,&p1->time,&p1->price); p2=p1; p1=(structtushu*)malloc(sizeof(structtushu)); p2->next=p1; break; } } if(p1->price!=-1) p2->next=NULL; else head=NULL; system("cls"); printf("\n\n\n\t\t\t图书信息输入结束!\n\n\n"); system("pause");system("cls"); printf("\n\n\n\t\t\t是否保留图书信息?(1.是/2.否):"); scanf("%d",&x); if(x==1) fprint(head); else { system("cls"); printf("\n\n\n\t\t\t文件没有被保留!\n\n\n\n"); system("pause"); system("cls"); menu(); }}//------------------------voidfprint(structtushu*head){ structtushu*p1; if((fp=fopen("tushu_list.txt","a"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); } if(head==NULL) { printf("没有图书保留!\n"); system("pause"); system("cls"); menu(); } for(p1=head;p1!=NULL;p1=p1->next)/*遍历*/ fprintf(fp,"%-10s%-30s%-20s%-20s%-20s%.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/ fclose(fp); system("cls"); printf("\n图书信息已成功保留到文件tushu_list.txt中!\n");system("pause");system("cls");getchar();menu();}//---------------------voidfprint_(structtushu*head){ structtushu*p1; chara[31]; printf("请输入你保留文件!\n"); scanf("%s",a); if((fp=fopen(a,"w"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); }if(head==NULL){ system("cls"); printf("没有图书!\n"); system("pause"); system("cls"); menu();} for(p1=head;p1!=NULL;p1=p1->next) fprintf(fp,"%-10s%-30s%-20s%-20s%-20s%.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/fclose(fp);system("cls");printf("\n图书信息已成功保留到文件%s中!\n",a);system("pause");system("cls");menu();}//-------------------------voidhfprint(structtushu*head){ structtushu*p1; if((fp=fopen("tushu_list.txt","a"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); } if(head==NULL) { printf("没有还书!\n"); xmenu(); } for(p1=head;p1!=NULL;p1=p1->next)/*遍历*/ fprintf(fp,"%-10s%-30s%-20s%-20s%-20s%.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/ fclose(fp); xmenu();}//----------------------voidjfprint_(structtushu*head){ structtushu*p1; if((fp=fopen("tushu_list.txt","w"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); } if(head==NULL) { xmenu(); } for(p1=head;p1!=NULL;p1=p1->next) { fprintf(fp,"%-10s%-30s%-20s%-20s%-20s%.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price);/*将图书信息写入文件*/ } fclose(fp); system("cls"); getchar(); xmenu();}//------------------------voidjsprint(jieshu*h){ structjieshu*pj; if((fp3=fopen("jieshu_list.txt","a"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); } for(pj=h;pj!=NULL;pj=pj->next) fprintf(fp3,"%-10d%-10s%-30s%-20s%-20s%-20s%.0lf%.2lf\n",pj->xuehao,pj->num,pj->name,pj->writer,pj->press,pj->kind,pj->time,pj->price); fclose(fp3);}//-----------------------structtushu*create(){ structtushu*head=NULL,*p,*p1,*p2; if((fp=fopen("tushu_list.txt","r"))==NULL)/*先安全打开目录文件*/ { printf("Fileopenerror!\n"); system("pause"); exit(0); } while(!feof(fp))/*读取并创建链表*/ { p=(structtushu*)malloc(sizeof(structtushu)); p->price=-1; fscanf(fp,"%s%s%s%s%s%lf%lf",p->num,p->name,p->writer,p->press,p->kind,&p->time,&p->price); if(p->price==-1) { free(p); break; } if(head==NULL) { head=p; p1=p; p1->next=NULL; } else { p1->next=p; p2=p1; p1=p; p1->next=NULL; } } fclose(fp); returnhead;}//-------------------------structjieshu*jcreate(){ structjieshu*head=NULL,*p,*p1,*p2; if((fp3=fopen("jieshu_list.txt","r"))==NULL) { printf("Fileopenerror!\n"); system("pause"); exit(0); } while(!feof(fp3)) { p=(structjieshu*)malloc(sizeof(structjieshu)); p->price=-1; fscanf(fp3,"%d%s%s%s%s%s%lf%lf",&p->xuehao,p->num,p->name,p->writer,p->press,p->kind,&p->time,&p->price); if(p->price==-1) { free(p); break; } if(head==NULL) { head=p; p1=p; p1->next=NULL; } else { p1->next=p; p2=p1; p1=p; p1->next=NULL; } } fclose(fp3); returnhead; }//------------------------------structjieshu*borrowcreate(structtushu*k,structjieshu*h){structjieshu*head;head=(structjieshu*)malloc(sizeof(structjieshu));if(h==NULL){ h=head; h->xuehao=denglu; strcpy(h->num,k->num); strcpy(h->name,k->name); strcpy(h->writer,k->writer); strcpy(h->press,k->press); strcpy(h->kind,k->kind); h->time=k->time; h->price=k->price; h->next=NULL; returnh; } else { head->xuehao=denglu; strcpy(head->num,k->num); strcpy(head->name,k->name); strcpy(head->writer,k->writer); strcpy(head->press,k->press); strcpy(head->kind,k->kind); head->time=k->time; head->price=k->price; head->next=h; returnhead; }}//--------------------------voidgBrowse(structtushu*head){ structtushu*p1; printf("编号书名作者出版社类别出版时间价格\n"); for(p1=head;p1!=NULL;p1=p1->next) { printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price); } system("pause"); system("cls"); menu();}//----------------------------voidxBrowse(structtushu*head){ structtushu*p1; printf("编号书名作者出版社类别出版时间价格\n"); for(p1=head;p1!=NULL;p1=p1->next) {printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price); } system("pause"); system("cls"); xmenu();}//-----------------------------voidcount(structtushu*head)/*统计图书数目*/{ intn=0; structtushu*p1; for(p1=head;p1!=NULL;p1=p1->next) n++; printf("\n此系统统计在内图书共有%d册。\n",n);/*计算并输出图书数目*/ system("pause"); system("cls"); menu();}//----------------------------voidFindofname(structtushu*head)/*按书名查询图书*/{ inti=0,n; charb[31]; structtushu*p; p=head; printf("\n请输入要查询图书名称:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->name,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) { system("cls"); printf("\n对不起!没有找到名为《%s》图书!\n",b); system("pause"); } printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) gfind(); else { system("cls"); menu(); }}//------------------------------voidFindofwriter(structtushu*head){ inti=0,n; charb[21]; structtushu*p; p=head; printf("\n请输入要查询图书作者姓名:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->writer,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) { system("cls"); printf("\n对不起!没有找到'%s'所著相关图书!\n",b); system("pause"); } printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) gfind(); else { system("cls"); menu(); }}//----------------------------------voidFindofkind(structtushu*head){ inti=0,n; charb[21]; structtushu*p; p=head; printf("\n请输入您要查询图书类别:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->kind,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) { system("cls"); printf("\n对不起!没有找到类别为'%s'图书!\n",b); system("pause"); } printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) gfind(); else { system("cls"); menu(); }}//---------------------------------voidxFindofname(structtushu*head)/*按书名查询图书*/{ inti=0,n; charb[31]; structtushu*p; p=head; printf("\n请输入要查询图书名称:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->name,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) { system("cls"); printf("\n对不起!没有找到名为《%s》图书!\n",b); system("pause"); } printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) xfind(); else { system("cls"); xmenu(); }}//--------------------------voidxFindofwriter(structtushu*head){ inti=0,n; charb[21]; structtushu*p; p=head; printf("\n请输入要查询图书作者姓名:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->writer,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) system("cls"); printf("\n对不起!没有找到'%s'所著相关图书!\n",b); system("pause"); printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) xfind(); else { system("cls"); xmenu(); }}//-----------------------voidxFindofkind(structtushu*head){ inti=0,n; charb[21]; structtushu*p; p=head; printf("\n请输入您要查询图书类别:"); scanf("%s",b); while(p!=NULL) { if(strcmp(p->kind,b)==0) { printf("编号书名作者出版社类别出版时间价格\n"); printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p->num,p->name,p->writer,p->press,p->kind,p->time,p->price); i++; } p=p->next; } if(i==0) system("cls"); printf("\n对不起!没有找到类别为'%s'图书!\n",b); system("pause"); printf("\n\n\n\t\t\t是否继续查找图书信息?(1.是/其它.返回):"); scanf("%d",&n); if(n==1) xfind(); else { system("cls"); xmenu(); }}//--------------------------voidSort_time(structtushu*head){ structtushu*p1,*p2,*p3,*p4=NULL,*p5; intx; for(p1=head;p1->next!=p4;) { for(p2=p1;p2->next!=p4;) { if(p2->time>p2->next->time) { if(p2==p1) { p1=p2->next; p2->next=p1->next; p1->next=p2; p3=p1; } else { p3->next=p2->next; p3=p2->next; p2->next=p3->next; p3->next=p2; } } else { p3=p2; p2=p2->next; } } p4=p2; } printf("编号书名作者出版社类别出版时间价格\n"); for(p5=p1;p5!=NULL;p5=p5->next) printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p5->num,p5->name,p5->writer,p5->press,p5->kind,p5->time,p5->price); system("pause"); system("cls"); printf("\n\n\n\t\t\t是否保留图书信息?(1.是/2.否(返回)):"); scanf("%d",&x); if(x==1) fprint_(p1); else system("cls"); printf("\n\n\n\t\t\t没有被保留到文件!\n\n\n\n"); system("pause"); system("cls"); menu(); return;}//----------------------------voidSort_price(structtushu*head){ structtushu*p1,*p2,*p3,*p4=NULL,*p5; intx; for(p1=head;p1->next!=p4;) { for(p2=p1;p2->next!=p4;) { if(p2->price>p2->next->price) { if(p2==p1) { p1=p2->next; p2->next=p1->next; p1->next=p2; p3=p1; } else { p3->next=p2->next; p3=p2->next; p2->next=p3->next; p3->next=p2; } } else { p3=p2; p2=p2->next; } } p4=p2; } printf("编号书名作者出版社类别出版时间价格\n"); for(p5=p1;p5!=NULL;p5=p5->next) printf("%-10s%-30s%-20s%-20s%-20s%-10.0lf%.2lf\n",p5->num,p5->name,p5->writer,p5->press,p5->kind,p5->time,p5->price); system("pause"); system("cls"); printf("\n\n\n\t\t\t是否保留图书信息?(1.是/2.否(返回)):"); scanf("%d",&x); if(x==1) fprint_(p1); else system("cls"); printf("\n\n\n\t\t\t没有被保留到文件!\n\n\n\n"); system("pause"); system("cls"); menu(); return;}//------------------------------voidSort_num(structtushu*head){ structtushu*p1,*p2,*p3,*p4=NULL,*p5; intx; for(p1=head;p1->next!=p4;) //对链表进行从大到小排序(这里用冒泡法) //p1使之总是指向头结点,p4使之总是指向已排序好最前面结点 //p3作为中介,保留p2上一个结点 { for(p2=p1;p2->next!=p4;) {

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论