




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct linkchar number100;char bookname100;char author100;char publish100;char time100;char status100;float price;struct link *next;link;link *Cbook();void mainmenu();void menu1();void glmenu();void cxmenu();void jhmenu()
2、;void print(link*head);void hold(link*head);void holdcx(link*t);link *findnumber(link*head);link *findbookname(link*head);link *findauthor(link*head);link *add(link*head);link *sortnumber(link*head);link *delbook(link*head);link *revamp(link*head);link *borrowbook(link*head);link *returnbook(link*he
3、ad);int main()int a,b,c,d,e;link *h,*t;L:system("cls"); mainmenu(); while(1) scanf("%d",&a); switch(a) case 1: B:system("cls"); menu1(); while(1) scanf("%d",&b); switch(b) case 1: h=Cbook(); break; case 2: system("cls"); glmenu(); while(1) sc
4、anf("%d",&c); switch(c) case 1: print(h); break; case 2: h=add(h); h=sortnumber(h); print(h); break; case 3: revamp(h); break; case 4: h=delbook(h); print(h); break; case 5: hold(h); break; case 6: goto B; break; break; case 3: system("cls"); cxmenu(); while(1) scanf("%d
5、",&d); switch(d) case 1: print(h); break; case 2: t=findnumber(h); if(t=NULL) printf("抱歉,沒有找到您要查詢的圖書!"); else printf("您想要查詢的為:"); printf("n"); printf("n*n"); printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n"); printf("%st%
6、st%st%st%st",t->number,t->bookname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status); break; case 3: t=findbookname(h); if(t=NULL) printf("抱歉,沒有找到您要查詢的圖書!"); else printf("您要查詢的圖書為:"); printf("n&qu
7、ot;); printf("n*n"); printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n"); printf("%st%st%st%st%st",t->number,t->bookname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status); break; case
8、 4: t=findauthor(h); if(t=NULL) printf("抱歉,沒有找到您要查詢的圖書!"); else printf("您要查詢的圖書為:"); printf("n"); printf("n*n"); printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n"); printf("%st%st%st%st%st",t->number,t->bookname,t->au
9、thor,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status); break; case 5: holdcx(t); break; case 6: goto B; break; break; case 4: system("cls"); jhmenu(); while(1) scanf("%d",&e); switch(e) case 1: borrowbook(h); break; case
10、 2: returnbook(h); break; case 3: goto B; break; break; case 5: hold(h); break; case 6: system("cls"); menu1(); break; case 7: goto L; break; break; case 0: printf("ttt感謝您的使用,再見!"); exit(0); ; return 0; link *Cbook()int n=0;link *p,*q,*head;FILE *fp;fp=fopen("圖書信息.txt",
11、"r+");if(fp=NULL)printf("沒有找到文件,請檢查.");p=(link *)malloc(sizeof(link);if(p=NULL)printf("申請內(nèi)存出錯!n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time);fscanf(fp,"%f",&p->price);fscanf(fp,"%s",p-&g
12、t;status);while(feof(fp)=0)n+;if(n=1)head=p;elseq=p;p=(link *)malloc(sizeof(link);if(p=NULL)printf("申請內(nèi)存出錯!n");fscanf(fp,"%s%s%s%s%s",p->number,p->bookname,p->author,p->publish,p->time); fscanf(fp,"%f",&p->price); fscanf(fp,"%s",p->sta
13、tus); q->next=p;p->next=NULL;fclose(fp);printf("信息已錄入!");return head;void mainmenu()printf("n*n");printf("n 歡迎使用圖書管理系統(tǒng) n");printf("n 1.進(jìn)入系統(tǒng) n");printf("n 0.退出系統(tǒng) n");printf("n*n");printf("n請選擇:");void menu1()printf("n*n&
14、quot;);printf("n 1.錄入所有圖書信息 n");printf("n 2.進(jìn)入圖書管理系統(tǒng) n");printf("n 3.進(jìn)入圖書查詢系統(tǒng) n");printf("n 4.進(jìn)入圖書借還系統(tǒng) n");printf("n 5.保存所有圖書信息 n");printf("n 6.顯示菜單 n");printf("n 7.返回上級菜單 n");printf("n*n");printf("請選擇:");void
15、glmenu()printf("n*n"); printf("n 1.顯示所有圖書信息 n");printf("n 2.添加一本圖書信息 n");printf("n 3.修改一本圖書信息 n");printf("n 4.刪除一本圖書信息 n");printf("n 5.保存所有圖書信息 n");printf("n 6.返回上級菜單 n");printf("n*n");printf("請選擇:");void cxmen
16、u()printf("n*n"); printf("n 1.顯示所有圖書信息 n");printf("n 2.按編號查詢圖書 n");printf("n 3.按書名查詢圖書 n");printf("n 4.按作者查詢圖書 n");printf("n 5.保存所查詢圖書信息 n");printf("n 6.返回上級菜單 n");printf("n*n");printf("請選擇:");void jhmenu()prin
17、tf("n*n");printf("n 1.借書 n");printf("n 2.還書 n");printf("n 3.返回上級菜單 n");printf("n*n");printf("請選擇:");void print(link *head)link *p;p=head;if(p=NULL)printf("文件中沒有圖書信息n");elseprintf("n");printf("n*n");printf("
18、;n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n");while(p!=NULL)printf("n"); printf("%stt%stt%stt%stt%s",p->number,p->bookname,p->author,p->publish,p->time);printf("tt%.2f",p->price);printf("tt%s",p->status);printf("n");p=p->next;void h
19、old(link *head)link *p;FILE *fp;fp=fopen("圖書信息.txt","w+");if(fp=NULL)printf("文件操作出錯!");exit(1);p=head;for(;p!=NULL;p->next)fprintf(fp,"n");fprintf(fp,"%stt%stt%stt%stt%s",p->number,p->bookname,p->author,p->publish,p->time);fprintf(f
20、p,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fclose(fp);printf("信息已保存!");void holdcx(link *t)link *p=NULL;FILE *fp;fp=fopen("查詢.txt","a+");p=t;fprintf(fp,"查詢到的信息為:n");fprintf(fp,"n");fprintf(fp,"n*n");fprintf(
21、fp,"n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n");fprintf(fp,"n");fprintf(fp,"%stt%stt%stt%stt%s",p->number,p->bookname,p->author,p->publish,p->time);fprintf(fp,"tt%.2f",p->price);fprintf(fp,"tt%s",p->status);fprintf(fp,"n");fclose
22、(fp);printf("信息已保存!");link *findnumber(link *head)char key100;link *h,*t1=NULL;printf("請輸入圖書的編號:");getchar();gets(key);for(h=head;h!=NULL;h=h->next)if(strcmp(key,h->number)=0)t1=h;break;return t1;link *findbookname(link *head)char key100;link *h,*t2=NULL;printf("請輸入圖書的
23、書名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next)if(strcmp(key,h->bookname)=0)t2=h;break;return t2;link *findauthor(link *head)char key100;link *h,*t3=NULL;printf("請輸入作者姓名:");getchar();gets(key);for(h=head;h!=NULL;h=h->next)if(strcmp(key,h->author)=0)t3=h;break;retur
24、n t3;link *add(link *head)link *h,*h1;h1=head;h=(link *)malloc(sizeof(link);if(h=NULL)printf("申請內(nèi)存出錯!");exit(1);printf("請輸入添加圖書的信息:");printf("n");printf("n*n");printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n");printf("n");scanf("%stt%stt%stt%s
25、tt%s",h->number,h->bookname,h->author,h->publish,h->time); scanf("tt%f",&h->price);scanf("tt%s",h->status);h->next=h1;return h;link *sortnumber(link *head)link *p,*q,*temp;temp=(link *)malloc(sizeof(link);if(temp=NULL)printf("申請內(nèi)存出錯!");e
26、xit(1);for(p=head;p!=NULL;p=p->next)for(q=p->next;q!=NULL;q=q->next)if(strcmp(p->number,q->number)>0)strcpy(temp->number,p->number);strcpy(temp->bookname,p->bookname);strcpy(temp->author,p->author);strcpy(temp->publish,p->publish);strcpy(temp->time,p->
27、time);temp->price=p->price;strcpy(temp->status,p->status);strcpy(p->number,q->number);strcpy(p->bookname,q->bookname);strcpy(p->author,q->author);strcpy(p->publish,q->publish);strcpy(p->time,q->time);p->price=q->price;strcpy(p->status,q->status);
28、strcpy(q->number,temp->number);strcpy(q->bookname,temp->bookname);strcpy(q->author,temp->author);strcpy(q->publish,temp->publish);strcpy(q->time,temp->time);q->price=temp->price;strcpy(q->status,temp->status);return head;link *delbook(link *head)int k=0;char
29、 str10;link *h,*t,*p;h=t=p=head;printf("請輸入要刪除的圖書名:");getchar();gets(str);for(;p!=NULL;p->next)k+;if(k>2)t=t->next;if(strcmp(p->bookname,str)=0)&&(k=1)h=p->next;else if(strcmp(p->bookname,str)=0&&k>1)t->next=p->next;else if(strcmp(p->bookname,s
30、tr)=0&&p->next=NULL)t=NULL;return h;link *revamp(link *head)link *h,*t;h=head;t=findbookname(h);if(t=NULL)printf("沒有找到.");elseprintf("修改前圖書信息為:");printf("n");printf("n*n"); printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n");
31、printf("%stt%stt%stt%stt%s",t->number,t->bookname,t->author,t->publish,t->time); printf("tt%.2f",t->price); printf("tt%s",t->status);printf("n"); printf("請輸入這本書(書名除外)所有信息:n"); printf("n*n"); printf("n編號tt書名tt作者tt出版
32、社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n"); scanf("%stt%stt%stt%stt%s",t->number,t->bookname,t->author,t->publish,t->time); scanf("tt%2f",&t->price); scanf("tt%s",t->status);printf("修改后圖書信息為:n");printf("n");printf("n*n"); printf("n編號tt書名tt作者tt出版社tt出版時(shí)間tt價(jià)格tt狀態(tài)n"); printf("n"); printf("%stt%stt%stt%stt%s",t->number,t->bookname,t->author,t->publish,t->time); printf("
溫馨提示
- 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)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 化工項(xiàng)目建設(shè)合同范本
- 0物業(yè)合同范本
- 廠家和平臺合同范本
- 吊車交易合同范例
- 吹塑加工采購合同范例
- 單位貨車出售合同范本
- 農(nóng)村公墓建設(shè)合同范本
- 信貸擔(dān)保合同范本
- 吊裝安裝服務(wù)合同范本
- 個(gè)人投資股票借款合同范本
- 江蘇省三級綜合醫(yī)院評審標(biāo)準(zhǔn)實(shí)施細(xì)則2017版
- 貴州區(qū)域地質(zhì)地史概述
- Aptitude態(tài)度的重要性
- 監(jiān)理大綱維修改造項(xiàng)目
- 中國著名的塔課件
- 邢臺市區(qū)土地級別及基準(zhǔn)地價(jià)表
- 《推薦》500kV輸電線路應(yīng)急處置預(yù)案6個(gè)
- 李小建《經(jīng)濟(jì)地理學(xué)》(電子版)
- 中央空調(diào)安裝施工組織設(shè)計(jì)方案(水、多聯(lián)機(jī))
- 2022年最新蘇教版五年級下冊科學(xué)全冊教案
- 咖啡樹的修剪方法和技術(shù)_種植技巧
評論
0/150
提交評論