为了正常的体验网站,请在浏览器设置里面开启Javascript功能!
首页 > 2023年C语言程序设计(图书管理系统)源代码

2023年C语言程序设计(图书管理系统)源代码

2023-03-20 3页 doc 25KB 8阅读

用户头像 个人认证

坚持101

暂无简介

举报
2023年C语言程序设计(图书管理系统)源代码C语言程序设计(图书管理系统)源代码#include"stdio.h"#include#include/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node{intnum;charleibie[20];charname[30];charauthor[20];charpress[20];chartime[20];...
2023年C语言程序设计(图书管理系统)源代码
C语言程序设计(图书管理系统)源代码#include"stdio.h"#include#include/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node{intnum;charleibie[20];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;structbook_node*next;};FILE*fpp;/*定义fpp为全局变量*/structbook_node*head,*tail,*p;introot();/*核查权限的函数*/intinputchioce();/*显示主菜单的函数*/voidsave();/*保存链表为文件的函数覆盖以前的信息*/voidsave1();/*保存链表为文件的函数不覆盖以前的信息只在创立时调用一次*/structbook_node*wjtolb();/*从文件中读取数据并建立图书信息的链表的函数*/intluruxinxi();/*录入学生信息的函数*/structbook_node*luruxinxi_chuangjian();/*创立图书信息的函数*/structbook_node*luruxinxi_charu();/*插入图书信息的函数*/structbook_node*luruxinxi_shanchu();/*删除图书信息的函数*/structbook_node*luruxinxi_xiugai();/*修改图书信息的函数*/intliulanbook();/*阅读图书信息的函数*/intchaxunbook();/*查询图书信息的函数*/voidchaxunbook_num();/*按编号查询图书*/voidchaxunbook_name();/*按书名查询图书*/voidchaxunbook_price();/*按价格查询图书*/voidpaixubook();/*为图书排序的函数*/structbook_node*paixubook_price();/*为图书按价格排序的函数*/structbook_node*paixubook_time();/*为图书按出版时间排序的函数*/voidsfjx();/*写个小函数,判定能否继续,让程序更完美在排序中使用*/inttongjibook_shumu();/*统计图书数目的函数*/voidshiyongshuoming();/*使用讲明的函数*//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/intmain(){intchioce;chioce=root();/*核查用户能否有使用该管理系统的权限的函数*/if(chioce==1)/*若获得权限则返回值为1*/{system("cls");inputchioce();}exit(0);}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/intinputchioce()/*主菜单*/{intmychioce,x=-1;printf("\n++++++++++++++++++++++++++++++++++++++欢迎你++++++++++++++++++++++++++++++++++\n\n");printf("**+++++++++++++++++++++++++++++++++++主菜单+++++++++++++++++++++++++++++++**\n");printf("**1--录入〔删除修改〕图书信息****2--〔按规则〕查询图书信息**\n");printf("**3--阅读图书信息****4--为图书〔按规则〕排序**\n");printf("**5--统计图书〔数目〕****6--帮助**\n");printf("**0--退出系统******\n");printf("**++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++**\n");printf("\n恭喜你获得使用权限,请你选择:");scanf("%d",&mychioce);switch(mychioce){case1:{luruxinxi();break;}case2:{chaxunbook();break;}case3:{liulanbook();break;}case4:{paixubook();break;}case5:{tongjibook_shumu();printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}break;}case6:{shiyongshuoming();break;}case0:{printf("\n\n谢谢你的使用!!再见\n\n");break;}default:{system("cls");printf("\n选择有误,请重新选择:\n");inputchioce();}break;}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/introot(){intm=1,n=3,flag=0;charmima[20];do{printf("\n\n你好,欢迎使本图书信息管理系统!\n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("【如今进行权限核查】\n--------------------友谊提醒:你共有3次输入密码的时机!\n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");if(n==2||n==1){printf("注意:你已输入错误%d次剩余输入次数:%d请输入密码:",3-n,n);}if(n==3)printf("剩余输入次数:%d请输入密码:",n);scanf("%s",mima);if(strcmp(mima,"fuck")==0){flag=1;returnflag;}m++;n--;system("cls");}while(strcmp(mima,"fuck.")!=0&printf("\n\n对不起,你连续三次输入密码错误,没有使用该图书管理系统的权限!\n");exit(0);}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*wjtolb(structbook_node*head,int*n)/*从文件中读取数据并建立图书信息的链表的函数*/{FILE*fp;structbook_node*p,*p1,*p2;if((fp=fopen("1.txt","r"))==NULL){printf("打开文件失败!\n");exit(1);}while(!feof(fp)){(*n)++;p=(structbook_node*)malloc(sizeof(structbook_node));fscanf(fp,"%d%s%s%s%s%s%lf",&p->num,p->leibie,p->name,p->author,p->press,p->time,&p->price);if(head==NULL){head=p;p1=p;}else{p1->next=p;p2=p1;p1=p;}}p2->next=NULL;free(p);(*n)--;fclose(fp);returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/intluruxinxi(){intk;printf("|++++++++++++++++++++++++++++录入信息++++++++++++++++++++++++++++++++|\n");printf("|1--创立或添加图书信息****2--删除图书信息|\n");printf("|3--修改图书信息****0--还回主菜单|\n");printf("请你再次选择详细操作:");scanf("%d",system("cls");/*清屏*/switch(k){case1:{luruxinxi_chuangjian();break;}case2:{luruxinxi_shanchu();break;}case3:{luruxinxi_xiugai();break;}case0:{inputchioce();break;}default:{system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}break;}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*luruxinxi_chuangjian()/*创立图书信息的函数*/{intnum;charleibie[10];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;intsize=sizeof(structbook_node);head=tail=NULL;printf("\n请依次输入图书的\n编号类别书名作者出版社出版时间价格(以“0〞结束输入):\n");scanf("%d",if(num!=0)scanf("%s%s%s%s%s%lf",leibie,name,author,press,time,while(num!=0){p=(structbook_node*)malloc(size);p->num=num;strcpy(p->leibie,leibie);strcpy(p->name,name);strcpy(p->author,author);strcpy(p->press,press);strcpy(p->time,time);p->price=price;p->next=NULL;if(head==NULL)head=p;elsetail->next=p;tail=p;printf("\n请继续输入图书的\n编号类别书名作者出版社出版时间价格(以“0〞结束输入):\n");scanf("%d",if(num!=0){scanf("%s%s%s%s%s%lf",leibie,name,author,press,time,}}if(num==0)/*若判定数字为0,则退出*/{system("cls");save1(head);inputchioce();}returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidsave1(structbook_node*p1){/*将链表保存为文件的函数不覆盖以前的信息*/if((fpp=fopen("1.txt","a"))==NULL){printf("打开文件失败!");exit(0);}while(p1!=NULL){fprintf(fpp,"%d%s%s%s%s%s%lf\n",p1->num,p1->leibie,p1->name,p1->author,p1->press,p1->time,p1->price);p1=p1->next;}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidsave(structbook_node*p1)/*将链表保存为文件的函数覆盖以前的信息*/{if((fpp=fopen("1.txt","w"))==NULL){printf("打开文件失败!");exit(0);}while(p1!=NULL){fprintf(fpp,"%d%s%s%s%s%s%lf\n",p1->num,p1->leibie,p1->name,p1->author,p1->press,p1->time,p1->price);p1=p1->next;}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*luruxinxi_shanchu()/*删除某本图书信息〔按编号删除〕*/{intx=-1,n=0;intnumm;intnum;charleibie[10];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;structbook_node*ptr1,*ptr2;structbook_node*head=NULL;printf("\n所有的图书信息如下:\n");/*删除前先遍历所有图书,方便看清要删除哪一本*/if((fpp=fopen("1.txt","r"))==NULL)/*输入要删除的图书编号之前先遍历所有图书信息*/{printf("打开文件失败!");exit(0);}else{printf("\n\n编号类别书名作者出版社出版时间价格\n");while(!feof(fpp)){fscanf(fpp,"%d%s%s%s%s%s%lf",&num,leibie,name,author,press,time,printf("%d%s%s%s%s%s%lf\n",num,leibie,name,author,press,time,price);}}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}head=wjtolb(head,/*从文件中读取数据将数据创立为链表*/printf("\n输入需要删除的图书的编号:");scanf("%d",&numm);while(head!=NULL&&head->num==numm){ptr2=head;head=head->next;free(ptr2);}if(head==NULL)returnNULL;ptr1=head;ptr2=head->next;while(ptr2!=NULL){if(ptr2->num==numm){ptr1->next=ptr2->next;free(ptr2);}elseptr1=ptr2;ptr2=ptr1->next;}save(head);/*重新保存为文件*/printf("编号为%d的图书已删除并将删除后的信息保存至文件",numm);printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*luruxinxi_xiugai()/*修改图书信息的函数〔按编号修改〕*/{intn=0,x=-1,t;intnum;intnumm;charleibie[10];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;structbook_node*head=NULL;structbook_node*p;printf("\n所有的图书信息如下:\n");if((fpp=fopen("1.txt","r"))==NULL)/*输入要修改的图书编号之前先遍历所有图书信息*/{printf("打开文件失败!");exit(0);}else{printf("\n\n编号类别书名作者出版社出版时间价格\n");while(!feof(fpp)){fscanf(fpp,"%d%s%s%s%s%s%lf",&num,leibie,name,author,press,time,printf("%d%s%s%s%s%s%lf\n",num,leibie,name,author,press,time,price);}}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}printf("\n输入需要修改的图书的编号:");scanf("%d",system("cls");/*先遍历后选择完要修改的图书编号后清屏*/head=wjtolb(head,printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("1--修改图书编号2--修改图书类别\n");printf("3--修改图书书名4--修改图书作者\n");printf("5--修改图书出版社6--修改图书出版时间\n");printf("7--修改图书价格\n");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("编号为%d本图书的信息为:\n",numm);if(head!=NULL&&head->num==numm)/*修改头结点*/{printf("编号类别书名作者出版社出版时间价格\n");printf("%d%s%s%s%s%s%lf\n",head->num,head->leibie,head->name,head->author,head->press,head->time,head->price);printf("请选择需要修改的图书信息的成分:");scanf("%d",switch(t){case1:{printf("请输入图书%d的新编号:\n",numm);scanf("%d",head->num=num;break;}case2:{printf("请输入图书%d的新类别:\n",numm);scanf("%s",leibie);strcpy(head->leibie,leibie);break;}case3:{printf("请输入图书%d的新书名:\n",numm);scanf("%s",name);strcpy(head->name,name);break;}case4:{printf("请输入图书%d的新\n",numm);scanf("%s",author);strcpy(head->author,author);break;}case5:{printf("请输入图书%d的新出版社:\n",numm);scanf("%s",press);strcpy(head->press,press);break;}case6:{printf("请输入图书%d的新出版时间:\n",numm);scanf("%s",time);strcpy(head->time,time);break;}case7:{printf("请输入图书%d的新价格:\n",numm);scanf("%lf",head->price=price;break;}default:{system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}break;}save(head);printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}else/*要修改的不是头节点*/{p=head->next;}//do用do-while语句事不能对第二本图书进行修改//{p=p->next;}while(p!=NULL&&p->num!=numm);while(p!=NULL&&p->num!=numm){p=p->next;}if(p!=NULL&&p->num==numm)/*修改其他节点*/{printf("\n\n编号类别书名作者出版社出版时间价格\n");printf("%d%s%s%s%s%s%lf\n",p->num,p->leibie,p->name,p->author,p->press,p->time,p->price);printf("请选择需要修改的图书信息的成分:");scanf("%d",switch(t){case1:{printf("请输入图书%d的新编号:\n",numm);scanf("%d",p->num=num;break;}case2:{printf("请输入图书%d的新类别:\n",numm);scanf("%s",leibie);strcpy(p->leibie,leibie);break;}case3:{printf("请输入图书%d的新书名:\n",numm);scanf("%s",name);strcpy(p->name,name);break;}case4:{printf("请输入图书%d的新\n",numm);scanf("%s",author);strcpy(p->author,author);break;}case5:{printf("请输入图书%d的新出版社:\n",numm);scanf("%s",press);strcpy(p->press,press);break;}case6:{printf("请输入图书%d的新出版时间:\n",numm);scanf("%s",time);strcpy(p->time,time);break;}case7:{printf("请输入图书%d的新价格:\n",numm);scanf("%lf",p->price=price;break;}default:{system("cls");printf("选择有误,请重新选择:\n");inputchioce();}break;}save(head);printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/intliulanbook()/*阅读图书信息的函数*/{intnum;charleibie[10];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;intx=-1;if((fpp=fopen("1.txt","r"))==NULL){printf("打开文件失败!");exit(0);}else{printf("\n\n编号类别书名作者出版社出版时间价格\n");while(!feof(fpp)){fscanf(fpp,"%d%s%s%s%s%s%lf",&num,leibie,name,author,press,time,printf("%d\t%s\t%s\t%s\t%s\t%s\t%lf\n",num,leibie,name,author,press,time,price);}}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/intchaxunbook()/*查询图书信息*/{intk;intn=0;structbook_node*head=NULL;head=wjtolb(head,printf("|++++++++++++++++++++++++++++查询图书信息++++++++++++++++++++++++++++++++|\n");printf("|1--按编号查询图书信息****2--按书名查询图书信息|\n");printf("|3--按价格查询图书信息****0--还回主菜单|\n");printf("请你再次选择具体操作:");scanf("%d",system("cls");/*清屏*/switch(k){case1:{chaxunbook_num(head);break;}case2:{chaxunbook_name(head);break;}case3:{chaxunbook_price(head);break;}case0:{inputchioce();break;}default:{system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}break;}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidchaxunbook_num(structbook_node*h)/*按编号查询图书*/{intfound,flag=1,num;intx;structbook_node*p;do{found=0;p=h;printf("请输入需要查找的图书的编号:");scanf("%d",printf("\n");while(p!=NULL){if(p->num==num){if(found==0)printf("\n编号类别书名作者出版社出版时间价格\n");printf("%d%s%s%s%s%s%lf\n",p->num,p->leibie,p->name,p->author,p->press,p->time,p->price);found=1;/*假如要查询的图书为头节点内的图书输出后将标记found变为1*/}p=p->next;}if(found==0)/*若不为头节点found不变继续往后面查找*/printf("编号为%d的图书未找到!\n",num);printf("\n\n能否继续查找?〔继续--1/返回主菜单--0〕");scanf("%d",if(x==0)flag=0;if(x==1)flag=1;if(x!=1&&x!=0)flag=2;}while(flag==1);/*flag为判定能否需要继续的函数继续查找时flag为1用do-while控制循环*/if(flag==0){system("cls");inputchioce();}if(flag==2){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidchaxunbook_name(structbook_node*h)/*按书名查询图书*/{intfound,flag=1;charname[30];intx;structbook_node*p;do{found=0;p=h;printf("请输入需要查找的图书的书名:");scanf("%s",name);printf("\n");while(p!=NULL){if(strcmp(p->name,name)==0){if(found==0)printf("\n编号类别书名作者出版社出版时间价格\n");printf("%d%s%s%s%s%s%lf\n",p->num,p->leibie,p->name,p->author,p->press,p->time,p->price);found=1;}p=p->next;}if(found==0)printf("书名为(%s)的图书未找到!\n",name);printf("\n\n能否继续查找?〔继续--1/返回主菜单--0〕");scanf("%d",if(x==0)flag=0;if(x==1)flag=1;if(x!=1&&x!=0)flag=2;}while(flag==1);if(flag==0){system("cls");inputchioce();}if(flag==2){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidchaxunbook_price(structbook_node*h)/*按价格查询图书*/{intfound,flag=1;doubleprice;intx;structbook_node*p;do{found=0;p=h;printf("请输入需要查找的图书的价格:");scanf("%lf",printf("\n");while(p!=NULL){if(p->price==price){if(found==0)printf("\n编号类别书名作者出版社出版时间价格\n");printf("%d%s%s%s%s%s%lf\n",p->num,p->leibie,p->name,p->author,p->press,p->time,p->price);found=1;}p=p->next;}if(found==0)printf("价格为%lf的图书未找到!\n",price);printf("\n\n能否继续查找?〔继续--1/返回主菜单--0〕");scanf("%d",if(x==0)flag=0;if(x==1)flag=1;if(x!=1&&x!=0)flag=2;}while(flag==1);if(flag==0){system("cls");inputchioce();}if(flag==2){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidpaixubook()/*为图书排序的函数*/{intk;intn=0;structbook_node*head=NULL;head=wjtolb(head,printf("|++++++++++++++++++++++++为图书按规则排序+++++++++++++++++++++++++++++|\n");printf("|1--按价格为图书排序****2--按出版时间为图书排序|\n");printf("|0--还回主菜单**|\n");printf("请你再次选择详细操作:");scanf("%d",system("cls");/*清屏*/switch(k){case1:{head=paixubook_price(head);sfjx();break;}case2:{head=paixubook_time(head);sfjx();break;}case0:{inputchioce();break;}default:{system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}break;}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*paixubook_price(structbook_node*head)/*为图书按价格排序的函数*/{intn;structbook_node*p1,*p2,*p3,*p4;inti,j;intsize=sizeof(structbook_node);n=tongjibook_shumu();p1=head;p2=head->next;if(head==NULL||head->next==NULL)returnhead;if(p2->next==NULL){if(p1->priceprice)returnhead;else{p2->next=p1;p1->next=NULL;head=p2;save(head);printf("\n\n按价格排序操作已完成并保存完毕\n能否继续操作?请选择〔继续-1/退出-0〕");returnhead;}}for(i=1;inext=head;p3=p4;p1=head;p2=head->next;for(j=0;jprice>p1->price){p3=p1;p1=p2;p2=p2->next;}else{p1->next=NULL;p1->next=p2->next;p3->next=p2;p2->next=p1;p3=p2;p2=p1->next;}}head=p4->next;free(p4);}save(head);printf("\n\n按价格排序操作已完成并保存完毕\n能否继续操作?请选择〔继续-1/退出-0〕");returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidsfjx()/*写个小函数,判定能否继续,让程序更完美*/{intx=-1;scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/structbook_node*paixubook_time(structbook_node*head)/*为图书按出版时间排序的函数*/{intn;structbook_node*p1,*p2,*p3,*p4;inti,j;intsize=sizeof(structbook_node);n=tongjibook_shumu();p1=head;p2=head->next;if(head==NULL||head->next==NULL)returnhead;if(p2->next==NULL){if(strcmp(p1->time,p2->time)>0)returnhead;else{p2->next=p1;p1->next=NULL;head=p2;save(head);printf("\n\n按出版时间排序操作已完成并保存完毕\n能否继续操作?请选择〔继续-1/退出-0〕");returnhead;}}for(i=1;inext=head;p3=p4;p1=head;p2=head->next;for(j=0;jtime,p2->time)next;}else{p1->next=NULL;p1->next=p2->next;p3->next=p2;p2->next=p1;p3=p2;p2=p1->next;}}head=p4->next;free(p4);}save(head);printf("\n\n按出版时间排序操作已完成并保存完毕\n能否继续操作?请选择〔继续-1/退出-0〕");returnhead;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/inttongjibook_shumu()/*统计图书数目的函数*/{intnum;charleibie[10];charname[30];charauthor[20];charpress[20];chartime[20];doubleprice;intx=-1,n=0;if((fpp=fopen("1.txt","r"))==NULL){printf("打开文件失败!");exit(0);}else{while(!feof(fpp)){fscanf(fpp,"%d%s%s%s%s%s%lf",&num,leibie,name,author,press,time,n++;}}if(fclose(fpp)){printf("关闭文件失败!\n");exit(0);}printf("共有%d本图书",n-1);returnn-1;}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*//*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/voidshiyongshuoming()/*使用讲明的函数*/{intx=-1;system("cls");printf("\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~使用讲明~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("你好,欢迎使用本图书管理系统!\n1.首先你需要获得本系统的使用权限,进入本系统后,你有三次输入密码");printf("的时机,在三次内输入正确密码即可获得使用权限,三次输入错误后,系统将自动退出。\n2.本系统的主菜单");printf("包括录入图书信息;查询图书信息;阅读图书信息;为图书按规则排序排序等。\n3.录入图书子菜单又包括");printf("对图书信息的创立、删除和修改,查询和排序的子菜单中又包括详细的按某种方式查询和排序以及返回主菜单的详细选项。");printf("\n4.每一项详细操作都有结束提示,完成后又有能否继续或者返回主菜单的询问。这样,你就能够在你想要退出系统时退出,方便");printf("打开一次系统进行多项操作。\n希望你使用愉快!!!");printf("");printf("");printf("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");printf("\n\n能否继续操作?请选择〔继续-1/退出-0〕");scanf("%d",if(x==1){system("cls");inputchioce();}if(x==0){printf("\n\n谢谢你的使用!再见\n");exit(0);}if(x!=1&&x!=0){system("cls");printf("选择有误,默认返回主菜单,请重新选择:\n");inputchioce();}}/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
/
本文档为【2023年C语言程序设计(图书管理系统)源代码】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
热门搜索

历史搜索

    清空历史搜索