




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>struct tushu /*圖書結(jié)構(gòu)體*/char num10; /*編號*/char name20; /*書名*/char writer20; /*作者*/char press20; /*出版社*/char kind20; /*類別*/ double time; /*時間*/double price; /*價格*/struct tushu *next;struct stu /*學(xué)生結(jié)構(gòu)體*/int snum; /*學(xué)號*/char mima10; /
2、*密碼*/ struct stu *next;FILE *fp; /*圖書文件*/FILE *fp1; /*管理員信息文件*/ FILE *fp2; /*學(xué)生信息文件*/void menu(); /*管理員主菜單(管理員進(jìn)入對圖書及學(xué)生信息進(jìn)行管理操作)*/void xmenu(); /*學(xué)生主菜單(學(xué)生進(jìn)入可對圖書,密碼進(jìn)行操作)*/void gfind(); /*管理員查詢(管理員可按一定的方式查詢圖書)*/void xfind(); /*學(xué)生查詢(學(xué)生可按一定的方式查詢圖書)*/void secret(); /*管理員權(quán)限(管理員登陸所用,輸入錯誤次數(shù)過多自動退出)*/void sort
3、(); /*排序(管理員可按一定的方式對圖書進(jìn)行排序,排序完之后可選擇文件進(jìn)行保存)*/void fprint(struct tushu *head); /*保存(可追加的保存,如添加可用)*/void fprint_(struct tushu *head); /*保存(可覆蓋保存如修改,刪除,排序后用)*/void hfprint(struct tushu *head); /*還書保存(還書成功后自動保存到文件)*/void jfprint_(struct tushu *head); /*借書保存(借書成功之后自動從圖書館刪除)*/struct tushu * Input(); /*圖書添加
4、(可進(jìn)行圖書的添加)*/struct tushu * create(); /*從文件創(chuàng)建鏈表(從文件中讀出信息,建立單鏈表)*/void gBrowse(struct tushu *head); /*管理員瀏覽(對圖書進(jìn)行遍歷)*/void xBrowse(struct tushu *head); /*學(xué)生瀏覽(學(xué)生對圖書進(jìn)行遍歷)*/void count(struct tushu *head); /*統(tǒng)計數(shù)量(管理員可對圖書進(jìn)行統(tǒng)計)*/void Findofname(struct tushu *head); /*按書名查找*/void Findofwriter(struct tushu *
5、head); /*按作者查找*/void Findofkind(struct tushu *head); /*按類別查找*/void xFindofname(struct tushu *head); /*學(xué)生按書名查找*/void xFindofwriter(struct tushu *head); /*學(xué)生按作者查找*/void xFindofkind(struct tushu *head); /*學(xué)生按類別查找*/void Sort_time(struct tushu * head); /*按時間排序(管理員按時間對圖書進(jìn)行排序,排序完之后可選擇文件進(jìn)行保存)*/void Sort_pri
6、ce(struct tushu * head); /*按價格排序*/void Sort_num(struct tushu * head); /*按編號排序*/void Delete(struct tushu * head,char m15);/*按編號刪除(管理員可按編號刪除圖書)*/void Revise(struct tushu *head); /*修改(管理員可對圖書進(jìn)行修改,并選擇是否保存)*/void borrow(struct tushu *head); /*借書*/void huanshu(); /*還書(學(xué)生借完書之后進(jìn)行還書,若沒有圖書則不能借)*/void gxinxi()
7、; /*管理員信息(有管理員的賬號及密碼,可進(jìn)行修改)*/void xmima(struct stu *head1); /*學(xué)生密碼修改(學(xué)生可對自己的密碼進(jìn)行修改)*/struct stu * xcreate(); /*從文件創(chuàng)建學(xué)生信息(從文件讀出學(xué)生信息,建立學(xué)生鏈表)*/void xsecret(struct stu *head1); /*學(xué)生權(quán)限(學(xué)生登陸所用)*/void menu() /*管理員主菜單(管理員進(jìn)入對圖書及學(xué)生信息進(jìn)行管理操作)*/int choice,n=0;struct tushu *head;struct stu *head1,*p;char m15;ther
8、e:printf(" n"); printf(" socat 圖書管理系統(tǒng) n");printf(" n");printf(" 0退出系統(tǒng) n"); printf(" n");printf(" 1幫助 n");printf(" n");printf(" 2瀏覽圖書 n");printf(" n");printf(" 3統(tǒng)計圖書數(shù)目 n");printf(" n");printf
9、(" 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");p
10、rintf(" 10學(xué)生信息 n");printf(" n");printf(" 請選擇:");fflush(stdin);head=create();scanf("%d",&choice);if(choice=1) /help();printf("沒有內(nèi)容!n");system("pause");system("cls");menu();else if(choice=2)system("cls");if(head=NULL)p
11、rintf("沒有圖書,請先添加圖書!n");system("pause");system("cls");menu();gBrowse(head);else if(choice=3)system("cls");count(head);else if(choice=4)system("cls");if(head=NULL)printf("沒有圖書,請先添加圖書!n");system("pause");system("cls");menu(
12、);gfind();else if(choice=5)Input();else if(choice=6)system("cls");if(head=NULL)printf("沒有圖書,請先添加圖書!n");system("pause");system("cls");menu();sort(head);else if(choice=7)system("cls");if(head=NULL)printf("沒有圖書,請先添加圖書!n");system("pause&qu
13、ot;);system("cls");menu();Revise(head) ;else if(choice=8)if(head=NULL)printf("沒有圖書,請先添加圖書!n");system("pause");system("cls");menu();printf(" 請輸入想要刪除的圖書編號:"); scanf("%s",m);Delete(head,m);else if(choice=9)gxinxi();else if(choice=10)system(&qu
14、ot;cls");head1=xcreate();if(head1=NULL)printf("沒有學(xué)生信息,請到xuesheng_list.txt添加!n");system("pause");system("cls");menu();for(p=head1;p!=NULL;p=p->next)printf("學(xué)生學(xué)號 密碼n");printf("%d %sn",p->snum,p->mima);system("pause");system(&quo
15、t;cls");menu();else if(choice=0)system("cls");printf("nnnn");printf(" 感謝使用圖書管理系統(tǒng) nnn");exit(0);elsesystem("cls");printf("nnnn 輸入錯誤,請重新輸入! nnn ");system("pause");system("cls");n+;if(n=3)printf(" nnn 你錯誤次數(shù)太多,自動退出! nnn"
16、;);printf(" 感謝使用圖書管理系統(tǒng) nnn");system("pause");exit(0);goto there;void xmenu()/*學(xué)生主菜單(學(xué)生進(jìn)入可對圖書,密碼進(jìn)行操作)*/ struct tushu *head;struct stu *head1;int choice,n=0;there:printf(" n"); printf(" socat 圖書借閱系統(tǒng) n");printf(" n");printf(" 0退出系統(tǒng) n"); printf
17、(" 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");pr
18、intf(" n");printf(" 請選擇:");fflush(stdin);head=create();scanf("%d",&choice);if(choice=1) /xhelp();printf("沒有內(nèi)容!n");system("pause");system("cls");xmenu();else if(choice=2)system("cls");if(head=NULL)printf("沒有圖書!n");sys
19、tem("pause");system("cls");xmenu();xBrowse(head);else if(choice=3)if(head=NULL)printf("沒有圖書!n");system("pause");system("cls");xmenu();xfind();else if(choice=4)if(head=NULL)printf("沒有圖書!n");system("pause");system("cls");x
20、menu();borrow(head);else if(choice=5)huanshu(head);else if(choice=6)system("cls");head1=xcreate();if(head1=NULL)printf("學(xué)生信息被清空!n");system("pause");system("cls");xmenu();xmima(head1); ;else if(choice=0)system("cls");printf("nnnn");printf(&q
21、uot; 感謝使用圖書管理系統(tǒng) nnn");exit(0);elsesystem("cls");printf("nnnn 輸入錯誤,請重新輸入! nnn ");system("pause");system("cls");n+;if(n=3)printf(" nnn 你錯誤次數(shù)太多,自動退出! nnn");printf(" 感謝使用圖書管理系統(tǒng) nnn");system("pause");exit(0);goto there;void gfind(
22、)/*管理員查詢(管理員可按一定的方式查詢圖書)*/int choice,n=0;struct tushu *head;there:system("cls");printf(" n");printf(" socat 圖書借閱系統(tǒng) n");printf(" n");printf(" 0返回 n");printf(" n");printf(" 1按書名查找 n");printf(" n");printf(" 2按作者查找 n&qu
23、ot;);printf(" n");printf(" 3按類別查找 n");printf(" n");printf(" n");printf(" n");printf(" 請選擇:");fflush(stdin);head=create();scanf("%d",&choice);if(choice=1)system("cls");Findofname(head);else if(choice=2)system("cl
24、s");Findofwriter(head);else if(choice=3)system("cls");Findofkind(head);else if(choice=0)system("cls");menu();elsesystem("cls");printf("nnnn 輸入錯誤,請重新輸入! nnn ");system("pause");system("cls");n+;if(n=3)printf(" nnn 你錯誤次數(shù)太多,自動退出! nnn&
25、quot;);printf(" 感謝使用圖書管理系統(tǒng) nnn");system("pause");exit(0);goto there;void xfind() /*學(xué)生查詢(學(xué)生可按一定的方式查詢圖書)*/struct tushu *head;int choice,n=0;there:system("cls");printf(" n"); printf(" socat 圖書借閱系統(tǒng) n");printf(" n");printf(" 0返回 n"); p
26、rintf(" n");printf(" 1按書名查找 n");printf(" n");printf(" 2按作者查找 n");printf(" n");printf(" 3按類別查找 n");printf(" n");printf(" n");printf(" n");printf(" 請選擇:");fflush(stdin);head=create();scanf("%d"
27、;,&choice);if(choice=1)system("cls");xFindofname(head);else if(choice=2)system("cls");xFindofwriter(head);else if(choice=3)system("cls");xFindofkind(head);else if(choice=0)system("cls");xmenu();elsesystem("cls");printf("nnnn 輸入錯誤,請重新輸入! nnn
28、");system("pause");system("cls");n+;if(n=3)printf(" nnn 你錯誤次數(shù)太多,自動退出! nnn");printf(" 感謝使用圖書借閱系統(tǒng) nnn");system("pause");exit(0);goto there;void sort()struct tushu *head;int choice,n=0;there:system("cls");printf(" n"); printf(&q
29、uot; socat 圖書借閱系統(tǒng) n");printf(" n"); printf(" 0返回 n"); printf(" n"); printf(" 1按時間排序 n"); printf(" n"); printf(" 2按價格排序 n"); printf(" n"); printf(" 3按編號排序 n"); printf(" n"); printf(" n"); printf(&
30、quot; n"); printf(" 請選擇:");fflush(stdin);head=create();scanf("%d",&choice);if(choice=1)system("cls"); Sort_time(head);else if(choice=2)system("cls");Sort_price(head);else if(choice=3)system("cls");Sort_num(head);else if(choice=0)system("
31、;cls");menu();elsesystem("cls");printf("nnnn 輸入錯誤,請重新輸入! nnn ");system("pause");system("cls");n+;if(n=3)printf(" nnn 你錯誤次數(shù)太多,自動退出! nnn");printf(" 感謝使用圖書借閱系統(tǒng) nnn"); system("pause"); exit(0);goto there;struct tushu *Input() str
32、uct tushu *p1,*p2,*head,*ptr; char num;int x,i=0;system("cls");p1=(struct tushu *)malloc(sizeof(struct tushu); head=p1;p1->price=-1;while(i!=1)printf("請輸入編號,以'#'結(jié)束n");scanf("%s",p1->num);if(strcmp(p1->num,"#")=0)i=1;while(i!=1)printf("請依次
33、輸入書名 作者 出版社 類別 出版時間 價格n");scanf("%s%s%s%s%lf%lf", p1->name,p1->writer,p1->press,p1->kind,&p1->time,&p1->price);p2=p1;p1=(struct tushu *)malloc(sizeof(struct tushu); p2->next=p1;break;if(p1->price!=-1)p2->next=NULL;elsehead=NULL;system("cls"
34、);printf("nnnttt圖書信息輸入結(jié)束!nnn");system("pause"); system("cls");printf("nnnttt是否保存圖書信息?(1.是/2.否):");scanf("%d",&x); if(x=1) fprint(head);else system("cls");printf("nnnttt 文件沒有被保存!nnnn");system("pause");system("cls
35、");menu(); void fprint(struct tushu *head) struct tushu *p1; if(fp=fopen("tushu_list.txt","a")=NULL) printf("File open error!n"); exit(0); if(head=NULL)printf("沒有圖書保存!n");system("pause");system("cls");menu();for(p1=head;p1!=NULL;p1=p1-
36、>next) /*遍歷*/fprintf(fp,"%st%st%st%st%st%.0lft%lfn", 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("cl
37、s"); getchar(); menu();void fprint_(struct tushu *head) struct tushu *p1;char a20;printf("請輸入你保存的文件!n");scanf("%s",a);if(fp=fopen(a,"w")=NULL)printf("File open error!n"); exit(0); if(head=NULL) system("cls"); printf("沒有圖書!n"); system(&
38、quot;pause"); system("cls"); menu(); for(p1=head;p1!=NULL;p1=p1->next) fprintf(fp,"%st%st%st%st%st%.0lft%lfn", p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price );/*將圖書信息寫入文件*/ fclose(fp); system("cls"); printf("n 圖書信息已成
39、功保存到文件 %s 中!n",a); system("pause"); system("cls"); menu();void hfprint(struct tushu *head) struct tushu *p1; if(fp=fopen("tushu_list.txt","a")=NULL) printf("File open error!n"); exit(0); if(head=NULL)printf("沒有還書!n");xmenu();for(p1=hea
40、d;p1!=NULL;p1=p1->next) /*遍歷*/fprintf(fp,"%st%st%st%st%st%.0lft%lfn", p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price );/*將圖書信息寫入文件*/ fclose(fp);xmenu();void jfprint_(struct tushu *head) struct tushu *p1;if(fp=fopen("tushu_list.txt","
41、;w")=NULL)printf("File open error!n"); exit(0);if(head=NULL)xmenu();for(p1=head;p1!=NULL;p1=p1->next)fprintf(fp,"%st%st%st%st%st%.0lft%lfn", p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price );/*將圖書信息寫入文件*/fclose(fp);system("cls&q
42、uot;);getchar(); xmenu();struct tushu * create()struct tushu *head=NULL, *p,*p1,*p2;if(fp=fopen("tushu_list.txt","r")=NULL)/*先安全打開目錄文件*/ printf("File open error!n");exit(0); while(!feof(fp)/*讀取并創(chuàng)建鏈表*/ p=(struct tushu *)malloc(sizeof(struct tushu); p->price=-1;fscanf(
43、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; elsep1->next=p;p2=p1;p1=p;p1->next=NULL; fclose(fp);return head; void gBrowse(struct tushu *h
44、ead) struct tushu *p1; for(p1=head;p1!=NULL;p1=p1->next) printf("編號 書名 作者 出版社 類別 出版時間 價格n"); printf(" %st%st%st%st%st%.0lft%.2lfn", p1->num,p1->name,p1->writer,p1->press,p1->kind,p1->time,p1->price); system("pause"); system("cls"); menu(); void xBrowse(struct tushu *head) struct tushu *p1; for(p1=head;p1!=NULL;p1=p1->next)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 教材驗收合格報告范文
- 企業(yè)臨時用工合同簡單
- 二零二五年度三方知識產(chǎn)權(quán)仲裁合同模板:專利侵權(quán)糾紛解決協(xié)議
- 二零二五年度公立醫(yī)院聘用制護(hù)士勞動合同協(xié)議書
- 二零二五年度技術(shù)攻關(guān)師帶徒項目合作協(xié)議
- 二零二五年度新能源技術(shù)研發(fā)人員個人雇傭合同
- 2025年度餐飲外賣平臺入股投資合同
- 部編人教版四年級數(shù)學(xué)下學(xué)期期末復(fù)習(xí)攻堅習(xí)題
- 二零二五年度高品質(zhì)豬場租豬場養(yǎng)豬合同
- 2025年度綠化帶設(shè)計與養(yǎng)護(hù)一體化合同
- 09式 新擒敵拳 教學(xué)教案 教學(xué)法 圖解
- 《網(wǎng)店運營與管理》整本書電子教案全套教學(xué)教案
- 打印版 《固體物理教程》課后答案王矜奉
- CAD術(shù)語對照表
- 學(xué)術(shù)論文的寫作與規(guī)范課件
- 香港牛津新魔法Newmagic3AUnit4Mycalendar單元檢測試卷
- 中考《紅星照耀中國》各篇章練習(xí)題及答案(1-12)
- Q∕GDW 11612.43-2018 低壓電力線高速載波通信互聯(lián)互通技術(shù)規(guī)范 第4-3部分:應(yīng)用層通信協(xié)議
- 自動化物料編碼規(guī)則
- 第1本書出體旅程journeys out of the body精教版2003版
- [英語考試]同等學(xué)力英語新大綱全部詞匯
評論
0/150
提交評論