序
时间在流去,我们在长大。
嗨,这里是狐狸~~
今天是2022年的一月四,元旦小长假也过去了,新年新气象,新年新目标,我们要向前看,不要执意过去了,感谢过去,把握现在,展望未来,这是我们现在应该做的。好了,废话不多说,今天我们分享一个系统,确实也有许久没有分享过系统了,今天就给大家详细讲一下这个图书管理系统吧。
开发一个图书信息管理系统,图书信息包括:图书编号、书名、作者、出版社、类别、出版时间、价格等基本信息(也可以根据自己情况进行扩充,比如是否借出、库存量等)。使之能提供以下基本功能:
(1)图书信息录入功能(图书信息用文件保存)--输入
(2)图书信息浏览功能--输出
(3)查询功能(至少一种查询方式)、排序功能(至少一种排序方式):
①按书名查询
②按作者名查询 按照价钱排序 按出版时间排序等等
(4)图书信息的删除与修改
扩展功能:可以按照自己的程度进行扩展。比如
(1)简单的权限处理
(2)报表打印功能
(3)甚至根据自己情况,可以加上学生信息,并扩充为图书借阅系统。
(4)模糊查询
(5)综合查询
(6)统计功能 比如统计处某一类别的图书信息 或 筛选出小于指定数量库存的图书信息等等。
1 图书录入可以录入图书名,作者,出版社,出版日期,价格!录入图书编号时函数就会判断此 编号是否存在,若存在不能成功录入!
2 图书浏览可以浏览全部图书!
3 图书查询提供按图书编号模糊查询,按图书名关键字查询,按图书编号精确查询,按图书名精确 查询!模糊查询和关键字查询事通过比价字符串的相似度而实现的!
4 修改删除图书可以通过图书查询来查询操作的图书编号,通过编号操作!函数会提示用户是否调 用图书查询来找到自己想要操作的图书的编号。如果某一本图书已经被借阅那么用户就不能删 除该图书!
5 借阅图书通过学号和图书编号进行借阅!如果该学号是第一次借阅那么会提示用户输入自己的姓 名,并存入student.txt,方便以后借阅与归还!
6 归还图书先提供学号,然后程序会输出该学号借阅的所有图书,然后再通过编号归还!
7 借阅查询可查询某个学生已借但未归还的图书!
先建立结构体,定义结构体成员
typedef struct book/*图书结构体*/{char num[10]; /*书号*/char name[10]; /*书名*/char auth[10]; /*作者*/int count;int sum;}book;typedef struct borrow/*借书结构体*/{char id[20];char ur[20];char book[20];char bookid[20];struct borrow *next;}bbnode,*bblink;struct ur { char num[10];/* 学号 */ char pass[15];char name[15]; char x[10]; }; typedef struct unode { struct ur data; struct unode *next; }unode,*ulink; unode *os;
int login(ulink l){ /*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}';password[0]='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textco榜样5观后感心得体会lor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;市场营销毕业论文范文int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}';}/**********************密码过滤****************************/while(password[0]=='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*'); password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='int login(ulink l){/*****************登陆窗口初始化****************************/while(!flag){char ur_id[10],password[10],tmp;int i=0;ur_id[0]='\0';password[0]='\0';textbackground(179);clrscr();gotoxy(33,23);textcolor(yellow);cputs("esc = exit");textcolor(white);textbackground(179);box(1,1,80,24);h_line(2,3,78);gotoxy(15,2);cputs("login now plea input the ur__id and password");bar_(30,10,23,5,5);/******************账号过滤*********************/while(ur_id[0]=='\0'){gotoxy(31,11);textcolor(yellow);textbackground(5);cputs("ur__id:");gotoxy(31,13);cputs("password:");textbackground(179);textcolor(white);gotoxy(28,7);cputs("plea input the ur__id!");textbackground(179);textcolor(yellow);gotoxy(27,11);putch(272);gotoxy(27,13);putch(' ');gotoxy(40,11);tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=9&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textcolor(yellow);textbackground(5);putch(tmp);ur_id[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}ur_id[i]='\0';}/**********************密码过滤****************************/while(password[0]=='\0'){gotoxy(28,7);textbackground(179);textcolor(white);cputs(" input the password now ");textbackground(179);textcolor(yellow);gotoxy(27,13);putch(272);gotoxy(27,11);putch(' ');gotoxy(40,13);i=0;tmp=getch();if(tmp==27){flg=27;return 0;}while(tmp!='\r'&&i<=10&&(tmp>=64&&tmp<=90)||(tmp>=97&&tmp<=122||(tmp>=48&&tmp<=57))){textbackground(5);putch('*');password[i]=tmp;i++;tmp=getch();if(tmp==27){flg=27;return 0;}}password[i]='\0';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}';}/*************把账号和密码进行对比验证**************/if(!strcmp(ur_id,"admin")&&!strcmp(password,"admin")){return 2;}if(cmps(l,ur_id,password)){ return 1;}}}
void choo(){while(1){ textbackground(179);clrscr();gotoxy(33,2);textcolor(white);cputs("administrastor");textcolor(yellow);box(1,1,80,24);h_line(2,3,78);gotoxy(3,6);cputs(">>>-------------------------1.ur management----------------------------<<<");gotoxy(3,10);cputs(">>>-------------------------2.book management----------------------------<<<");gotoxy(3,14);cputs(">>>-------------------------3.borrow books-------------------------------<<<");gotoxy(30,22);textcolor(red);cputs("plea lect!!!");flg=getch();if(flg=='2')bookss();if(flg=='1')urs();if(flg=='3')borrow();if(flg==27){flg=-1;return;}}}void admin(){while(1){choo();if(flg=='1')bookss();if(flg=='2')urs();if(flg=='3')borrow();if(flg==27){return;}}}
void ur(ulink h){int flag;bblink l,p,r;/* 连表 */ file *fp; /* 文件指针 */ int count=0; l=(bbnode*)malloc(sizeof(bbnode)); l->next=null; r=l; fp=fopen(bfile,"rb"); if(fp==null) { fp=fopen(bfile,"wb"); } while(!feof(fp)) {p=(bbnode*)malloc(sizeof(bbnode)); if(fread(p,sizeof(bbnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ count++; } } while(1) {textbackground(179);clrscr();textcolor(yellow);box(1,1,80,24);h_line(2,3,78);gotoxy(3,2);textcolor(red);cputs("a.");textcolor(blue);cputs("my message ");textcolor(red);cputs("b.");textcolor(blue);cputs("modyfy my message ");textcolor(red);cputs("c.");textcolor(blue);cputs("my borrow ");textcolor(red);cputs("d.");textcolor(blue);cputs("arch book");textcolor(yellow);gotoxy(50,50);flag=getch(); switch(flag){ ca 'a':show(os);break; /*************添加用户**********/ca 'b':modify_ur(h);save(h);break;/*************删除用户**********/ca 'c':myborrow();break;ca 'd':urarch(); break;ca 27:return;} } }
图书的添加,包括用户添加以及管理员添加
void add(blink l){ bnode *p,*r,*s; char num[10]; r=l; s=l->next; while(r->next!=null) r=r->next; textcolor(red);gotoxy(25,4);cputs("input the message about book");gotoxy(31,10);textcolor(yellow);cputs("book id:");scanf("%s",num); p=(bnode *)malloc(sizeof(bnode)); while(s) { if(strcmp(s->data.num,num)==0) { textcolor(white);gotoxy(25,15);cputs("this id:");printf("'%s'",num); cputs("is exist!"); gotoxy(25,22);cputs("plea press any key to continue..."); gotoxy(255,252);getch(); return; } s=s->next; } strcpy(p->data.num,num); gotoxy(31,12);textcolor(yellow);cputs("input book name:"); scanf("%s",p->data.name); gotoxy(31,14);cputs("input your book auth:"); scanf("%s",p->data.auth); gotoxy(31,16);cputs("input your book count:"); scanf("%d",&p->data.count); bookcount=p->data.count+bookcount;p->data.sum=0;p->next=null; r->next=p; r=p; gotoxy(30,22);textcolor(red);cputs("add book success !!!");getch();textcolor(yellow);} /*******管理员添加用户*******/void add(ulink l){ unode *p,*r,*s; char num[10]; r=l; s=l->next; while(r->next!=null) r=r->next; textcolor(red);gotoxy(25,4);cputs("input the message about book");gotoxy(31,10);textcolor(yellow);cputs("ur id:");scanf("%s",num); p=(unode *)malloc(sizeof(unode)); while(s) { if(strcmp(s->data.num,num)==0) { gotoxy(25,15);cputs("this id:");printf("'%s'",num); cputs("is exist!"); gotoxy(25,22);textcolor(red);cputs("plea press any key to continue..."); gotoxy(255,252);getch(); return; } s=s->next; } strcpy(p->data.num,num); gotoxy(31,12);textcolor(yellow);cputs("input password:"); scanf("%s",p->data.pass); gotoxy(31,14);cputs("input your name:"); scanf("%s",p->data.name); gotoxy(31,16);cputs("input the x:"); scanf("%s",p->data.x); p->next=null; r->next=p; r=p; gotoxy(30,22);cputs("add ur success !!!");urcount++;getch();textcolor(yellow);}
用户查找以及管理员查找
/*******管理员查找图书*******/void qur(blink l){ int l; char findmess[20]; bnode *p; if(!l->next) { gotoxy(30,4);textcolor(white); cputs("not find bookdata!!!"); getch(); return; } textcolor(red);gotoxy(25,4);cputs("plea lect arch type !");gotoxy(10,8);textcolor(white);cputs("1.arch by id");gotoxy(10,10);cputs("2.arch by name");gotoxy(10,12);cputs("plea lect 1 or 2:");scanf("%d",&l); if(l==1) {gotoxy(36,8);textcolor(yellow);cputs("input the arch id:"); scanf("%s",findmess); p=locate(l,findmess,"num"); if(p) { gotoxy(36,12);textcolor(white);cputs("book id:");printf("%s",p->data.num);gotoxy(36,14);textcolor(white);cputs("book name:");printf("%s",p->data.name);gotoxy(36,16);textcolor(white);cputs("book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(white);cputs("book count:");printf("%d",p->data.count);getch();textcolor(yellow);gotoxy(30,21);cputs("arch success !!");}el {gotoxy(30,22);textcolor(red);cputs("not finde !!!"); getch();}}el if(l==2) /* 姓名 */{ gotoxy(36,8);textcolor(yellow);cputs("input the arch name:");scanf("%s",findmess); p=locate(l,findmess,"name"); if(p) { gotoxy(36,12);textcolor(white);cputs("book id:");printf("%s",p->data.num);gotoxy(36,14);textcolor(white);cputs("book name:");printf("%s",p->data.name);gotoxy(36,16);textcolor(white);cputs("book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(white);cputs("book count:");printf("%d",p->data.count);getch();textcolor(yellow);} el {textcolor(red);gotoxy(30,22);cputs("not finde !!!"); }} el {textcolor(red);gotoxy(30,22); cputs("error !!"); getch();}} /*******用户查找图书*******/void urarch(){ int l; char findmess[20]; bnode *p; blink l;/* 连表 */ file *fp; /* 文件指针 */ int count=0; bnode *p,*r;l=(bnode*)malloc(sizeof(bnode)); l->next=null; r=l; fp=fopen(file,"rb"); if(fp==null) { fp=fopen(file,"wb"); } while(!feof(fp)) { p=(bnode*)malloc(sizeof(bnode)); if(fread(p,sizeof(bnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; bookcount=bookcount+p->data.count;booksum=booksum+p->data.sum; r->next=p; r=p; /* 将该接点挂入连中 */ count++; }} fclo(fp); /* 关闭文件 */ if(!l->next) { gotoxy(30,4);textcolor(white); cputs("not find bookdata!!!"); getch(); return; } textcolor(red);gotoxy(25,4);cputs("plea lect delete type !");gotoxy(10,8);textcolor(white);cputs("1.arch by id");gotoxy(10,10);cputs("2.arch by name");gotoxy(10,12);cputs("plea lect 1 or 2:");scanf("%d",&l); if(l==1) {gotoxy(36,8);textcolor(yellow);cputs("input the arch id:"); scanf("%s",findmess); p=locate(l,findmess,"num"); if(p) { gotoxy(36,12);textcolor(white);cputs("book id:");printf("%s",p->data.num);gotoxy(36,14);textcolor(white);cputs("book name:");printf("%s",p->data.name);gotoxy(36,16);textcolor(white);cputs("book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(white);cputs("book count:");printf("%d",p->data.count-p->data.sum);getch();textcolor(yellow);}el {gotoxy(30,22);textcolor(red);cputs("not finde !!!"); getch();}}el if(l==2){ gotoxy(36,8);textcolor(yellow);cputs("input the arch name:");scanf("%s",findmess); p=locate(l,findmess,"name"); if(p) { gotoxy(36,12);textcolor(white);cputs("book id:");printf("%s",p->data.num);gotoxy(36,14);textcolor(white);cputs("book name:");printf("%s",p->data.name);gotoxy(36,16);textcolor(white);cputs("book author:");printf("%s",p->data.auth);gotoxy(36,18);textcolor(white);cputs("book count:");printf("%d",(p->data.count-p->data.sum));getch();textcolor(yellow);} el {textcolor(red);gotoxy(30,22);cputs("not finde !!!"); }} el {textcolor(red);gotoxy(30,22); cputs("error !!"); getch();}} /*******图书查找*******/int cmpbook(blink l,char id[],char na[]){ char findm[20];bnode *p; if(!l->next) { gotoxy(25,4);textcolor(red); cputs("not find book!!!"); getch(); return 0; } strcpy(findm,id);p=locate(l,findm,"num"); if(p) { strcpy(findm,na);p=locate(l,findm,"name"); if(p) { return 1;} el {textcolor(red);gotoxy(30,22);cputs("book name is null !!!"); getch();return 0;}}el {gotoxy(30,22);textcolor(red);cputs("book id is null !!!"); getch();return 0;} }
图书的删除
void del(blink l) { int l; bnode *p,*r; char findmess[20]; if(!l->next) { gotoxy(25,4);textcolor(red);cputs("=====高中女生>not thing could delete!\n"); getch();return; } textcolor(red);gotoxy(25,4);puts("plea lect delete type !");gotoxy(10,8);textcolor(white);cputs("1.delete by book id");gotoxy(10,10);cputs("2.delete by book name");gotoxy(10,12);cputs("plea lect 1 or 2:");scanf("%d",&l); if(l==1) { gotoxy(36,8);textcolor(yellow);cputs("input the delete id:"); scanf("%s",findmess); p=locate(l,findmess,"num"); if(p) { bookcount=bookcount-p->data.count;r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); gotoxy(30,22);textcolor(red);cputs("delete success!\n"); textcolor(yellow); } el {textcolor(red);gotoxy(30,22); cputs("error !!"); }} el if(l==2) { gotoxy(36,8);textcolor(yellow);cputs("input the delete name:"); scanf("%s",findmess); p=locate(l,findmess,"name"); if(p) { r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); gotoxy(30,22);textcolor(red);cputs("delete success!\n"); bookcount--;textcolor(yellow); } el{gotoxy(25,18);cputs("not find!!"); }} el{textcolor(red);gotoxy(30,现代移动通信技术22); cputs("error !!"); }getch();textcolor(yellow);}
void borrow(){while(1){int flag;bblink l,p,r;/* 连表 */ file *fp; /* 文件指针 */ int count=0; l=(bbnode*)malloc(sizeof(bbnode)); l->next=null; r=l; fp=fopen(bfile,"rb"); if(fp==null) { fp=fopen(bfile,"wb"); } while(!feof(fp)) {p=(bbnode*)malloc(sizeof(bbnode)); if(fread(p,sizeof(bbnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ count++; } borrowcount=count;} while(1) {textbackground(179);clrscr();textcolor(yellow);box(1,1,80,24);h_line(2,3,78);gotoxy(3,2);textcolor(red);cputs("b");textcolor(blue);cputs("orrow book ");textcolor(red);cputs("r");textcolor(blue);cputs("eturn book ");textcolor(red);cputs("s");textcolor(blue);cputs("earch borrow ");textcolor(yellow);printf("count: (borrow=%d)",borrowcount);textcolor(red);gotoxy(50,50);flag=getch(); switch(flag){ ca 'b':add_borrow(l);break; /*************添加用户**********/ca 'r':del_borrow(l);save_borrow(l);break;ca 's':qur_borrow(l);break;ca 27:return;} } }}
图书信息的储存
*******借书信息保存*******/void save_borrow(bblink l) { file* fp; bbnode *p; int flag=1,count=0; fp=fopen(bfile,"wb"); if(fp==null) { gotoxy(35,12);textcolor(red); cputs("open error!"); exit(1); } p=l->next; while(p) { if(fwrite(p,sizeof(bbnode),1,fp)==1) { p=p->next; count++; } el { flag=0; break; } } if(flag) { textcolor(red);gotoxy(30,24); /*** printf("save success.(saved%d.)",count);**调试的时候用的*/}fclo(fp); }
/* 还书的操作 */ void del_borrow(bblink l) { int l; bbnode *p,*r; bnode *l;char findmess[20];file *fp; /* 文件指针 */bnode *p,*r,*q;l=(bnode*)malloc(sizeof(bnode)); l->next=null; r=l; fp=fopen(file,"rb"); if(fp==null) { fp=fopen(file,"wb"); }while(!feof(fp)){ p=(bnode*)malloc(sizeof(bnode)); if(fread(p,sizeof(bnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ }}fclo(fp); /* 关闭文件 */ if(!l->next){gotoxy(30,4);textcolor(red);cputs("not book could return!\n");getch();return;}textcolor(red);gotoxy(25,4);puts("plea lect return type !");gotoxy(10,8); textcolor(white);cputs("1.return by borrow id");gotoxy(10,10);cputs("2.return by book name");gotoxy(10,12);cputs("plea lect 1 or 2:");scanf("%d",&l);if(l==1){gotoxy(36,8);textcolor(yellow);cputs("input the borrow id:");scanf("%s",findmess);p=locate_borrow(l,findmess,"num");if(p){ q=locate(l,findmess,"num");if(q) { q->data.sum=q->data.sum-1;save(l);} r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); gotoxy(30,22);textcolor(red);cputs("return success!\n"); borrowcount--;getch();textcolor(yellow); } el {gotoxy(30,22);textcolor(red);cputs("note find !!"); getch();}} el if(l==2) { gotoxy(36,8);textcolor(yellow);cputs("input the book name:"); scanf("%s",findmess); p=locate_borrow(l,findmess,"book");if(p) { q=locate(l,findmess,"name"); if(q) { q->data.sum=q->data.sum-1;save(l);} r=l; while(r->next!=p) r=r->next; r->next=p->next; free(p); gotoxy(30,22);textcolor(red);cputs("borrow success!\n"); borrowcount--;getch();textcolor(yellow); } el{gotoxy(30,18);textcolor(red);cputs("not find!!"); getch();}} el{gotoxy(30,22);textcolor(red);cputs("not finde !!"); getch();}textcolor(yellow);}
也分为用户和管理员两种情况
/* ****用于管理员修改用户资料 ***/void modify(ulink l) { unode *p; char findmess[20]; if(!l->next) {gotoxy(30,4);textcolor(red);cputs("not thing could modify!"); getch();return; } gotoxy(30,4);textcolor(red);cputs("modify ur message");gotoxy(25,8);textcolor(yellow);cputs("input the ur id:");scanf("%s",findmess); p=locate(l,findmess,"num"); if(p) { textcolor(yellow);gotoxy(25,10);printf("inpute the new id(old:%s):",p->data.num); scanf("%s",p->data.num); gotoxy(25,12);printf("input the new password(old:%s):",p->data.pass); scanf("%s",p->data.pass); gotoxy(25,14);printf("input the new name(old:%s):",p->data.name); scanf("%s",p->data.name); gotoxy(25,16);printf("input the new x(old:%s):",p->data.x); scanf("%s",p->data.x); gotoxy(30,20);textcolor(red);cputs("modify success !!!"); getch();textcolor(yellow);} el {gotoxy(30,16);textcolor(red);cputs("not finde !!!"); getch();}} /****供用户修改用户自己资料 */void modify_ur(ulink l){ unode *p; char findmess[20]; if(!l->next) {gotoxy(30,4);textcolor(red);cputs("not thing could modify!"); getch();return; } gotoxy(30,4);textcolor(red);cputs("modify ur message");gotoxy(33,8);textcolor(yellow);strcpy(findmess,os->data.num);printf("your id:%s",findmess);p=locate(l,findmess,"num"); if(p) { textcolor(yellow);gotoxy(24,10);printf("input the new password(old:%s):",p->data.pass); scanf("%s",p->data.pass); gotoxy(24,12);printf("input the new name(old:%s):",p->data.name); scanf("%s",p->data.name); gotoxy(24,14);printf("input the new x(old:%s):",p->data.x); scanf("%s",p->data.x); gotoxy(31,18);textcolor(red);cputs("modify success !!!"); getch();textcolor(yellow);} el {gotoxy(30,16);textcolor(red);cputs("not finde !!!"); getch();}}
/*******添加借书*******/void add_borrow(bblink l) { ulink h;/* 连表 */ file *fp; /* 文件指针 */ unode *q,*t;blink l;/* 连表 */ file *fp; /* 文件指针 */ int ttl; bnode *p,*r;char bookid[20];char bookname[20];char urid[20];bbnode *p,*r,*s; char num[10]; r=l; s=l->next; while(r->next!=null) r=r->next; l=(bnode*)malloc(sizeof(bnode)); l->next=null; r=l; fp=fopen(file,"rb"); if(fp==null) { fp=fopen(file,"wb"); } while(!feof(fp)) { p=(bnode*)malloc(sizeof(bnode)); if(fread(p,sizeof(bnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; bookcount=bookcount+p->data.count; r->next=p; r=p; /* 将该接点挂入连中 */ } } fclo(fp); /* 关闭文件 */ h=(unode*)malloc(sizeof(unode)); h->next=null; t=h;fp=fopen(ufile,"rb"); if(fp==null) { fp=fopen(ufile,"wb"); } while(!feof(fp)) { q=(unode*)malloc(sizeof(unode)); if(fread(q,sizeof(unode),1,fp)) /* 将文件的内容放入接点中 */ { q->next=null; t->next=q; t=q; /* 将该接点挂入连中 */ } } fclo(fp); textcolor(red);gotoxy(25,4);cputs("plea input thea message");gotoxy(30,10);textcolor(yellow);cputs("input borrow id:");scanf("%d",&ttl);itoa(ttl,num,10) ;p=(bbnode *)malloc(sizeof(bbnode));while(s) { if(strcmp(s->id,num)==0) { gotoxy(30,15);cputs("borrow id:");printf("'%s'",num); cputs("is exist!"); gotoxy(26,22);textcolor(red);cputs("plea press any key to continue..."); gotoxy(255,252);getch(); return; } s=s->next; } strcpy(p->id,num);gotoxy(31,12);textcolor(yellow);cputs("input book id:"); scanf("%s",bookid);gotoxy(31,14);textcolor(yellow);cputs("input book name:"); scanf("%s",bookname);/***************************************图书判断在否**春风里*************************************/ if(cmpbook(l,bookid,bookname)){strcpy(p->bookid,bookid);strcpy(p->book,bookname);gotoxy(31,16);cputs("input your id:"); scanf("%s",urid); /**************************************用户判断在否********************************/if(cmpur(h,urid)){strcpy(p->ur,urid);p->next=null; r->next=p; r=p; if(changeb(l,bookid)){gotoxy(30,22);cputs("borrow success !!!");save_borrow(l);borrowcount++; getch();}} } textcolor(yellow);}
查找自己借了哪些书
void myborrow(){int i; bblink l,p,r;/* 连表 */ file *fp; /* 文件指针 */ int count=0; l=(bbnode*)malloc(sizeof(bbnode)); l->next=null; r=l; fp=fopen(bfile,"rb"); if(fp==null) { fp=fopen(bfile,"wb"); } i=6;while(!feof(fp)) { p=(bbnode*)malloc(sizeof(bbnode)); if(fread(p,sizeof(bbnode),1,fp)) /* 将文件的内容放入接点中 */ { textcolor(white);gotoxy(30,4);cputs("your borrow book");if(strcmp(p->ur,os->data.num)==0){textcolor(yellow); gotoxy(20,i);printf("borrow id:%s\tbook id:%s\tbook name:%s",p->id,p->bookid,p->book);i++; p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ count++; } } myborrow=count;if(myborrow==0){textcolor(yellow);gotoxy(30,13);cputs("you no borrow !!"); } }fclo(fp);textcolor(yellow);gotoxy(65,2);printf("(borrow=%d)",myborrow);getch(); }
void borrow(){while(1){int flag;bblink l,p,r;/* 连表 */ file *fp; /* 文件指针 */ int count=0; l=(bbnode*)malloc(sizeof(bbnode)); l->next=null; r=l; fp=fopen(bfile,"rb"); if(fp==null) { fp=fopen(bfile,"wb"); } while(!feof(fp)) {p=(bbnode*)malloc(sizeof(bbnode)); if(fread(p,sizeof(bbnode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ count++; } borrowcount=count;} while(1) {textbackground(179);clrscr();textcolor(yellow);box(1,1,80,24);h_line(2,3,78);gotoxy(3,2);textcolor(red);cputs("b");textcolor(blue);cputs("orrow book ");textcolor(red);cputs("r");textcolor(blue);cputs("eturn book ");textcolor(red);cputs("s");textcolor(blue);cputs("earch borrow ");textcolor(yellow);printf("count: (borrow=%d)",borrowcount);textcolor(red);gotoxy(50,50);flag=getch(); switch(flag){ ca 'b':add_borrow(l);break; /*************添加用户**********/ca 'r':del_borrow(l);save_borrow(l);break;ca 's':qur_borrow(l);break;ca 27:return;} } } }
main(){ ulink h,os;/* 连表 */ file *fp; /* 文件指针 */ unode *p,*r;h=(unode*)malloc(sizeof(unode)); h->next=null; r=h; fp=fopen(ufile,"rb"); if(fp==null) { fp=fopen(ufile,"wb"); } while(!feof(fp)) { p=(unode*)malloc(sizeof(unode)); if(fread(p,sizeof(unode),1,fp)) /* 将文件的内容放入接点中 */ { p->next=null; r->next=p; r=p; /* 将该接点挂入连中 */ }}fclo(fp);system("wellcome");if(flg==27){flg=-1;return;}while(1){flag=login(h);if(flg==27){flg=-1;break;} if(flag==2){choo();flag=0;}if(flag==1){ur(h);flag=0;} } }
今天的代码量有点小多,难度也不小,用了大量的链表来储存数据,还有一些功能因为篇幅的问题没有放上来,总的来说,这个图书管理系统的功能是很全面的,无论从哪个角度来看。当然啦。有兴趣的同学可以进群领取完整的源码看看,绝对是一个不错的机会,可以说,你要是学会了这个系统,你的c语言在我看来就完全没有问题了,而且在数据结构一块,你也算是小成了,所以希望大家可以认真学习,争取早日掌握。
这也是2022年的第一篇文章了,希望2022继续加油,向大家分享更多有趣的、有用的知识,十分感谢大家的一路支持,后续我还会发布更多的项目源或者学习资料,希望大家可以持续关注。
到此这篇关于c语言大作业之图书管理系统的实现详程的文章就介绍到这了,更多相关c语言 图书管理系统内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!
本文发布于:2023-04-04 17:38:37,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/1dae1458bc5f951710548ab486ac3aff.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:C语言大作业之图书管理系统的实现详程.doc
本文 PDF 下载地址:C语言大作业之图书管理系统的实现详程.pdf
留言与评论(共有 0 条评论) |