版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、#include #include #include #include #include #include #define Key_UP 72#define Key_DOWN 80#define Key_ENTER 28#define Key_N 49#define Key_Y 21#define LEN sizeof(struct linklist)typedef struct book1/*圖書基本信息結(jié)構(gòu)體*/char name20;char writer30;char type20;char num20;char time20;char press20;char edition20;c
2、har ISBN40;float price;int count;int lendnum;bbasic;/*圖書資料基本信息:中圖法分類號(hào)、圖書編號(hào)、書名、作者(要考慮多個(gè)作者情況)、出版社、出版日期、ISBN、版次、定價(jià)、館藏?cái)?shù)、借閱數(shù)等。*/typedef struct book2/*圖書采購信息結(jié)構(gòu)體*/char name20;char writer20;char time15;int num;float price;float money;char bill 30;bpurchase;/*圖書采購信息:書名、作者、采購日期、采購數(shù)量、采購單價(jià)、采購金額、發(fā)票號(hào)碼、圖書編號(hào)等。*/typ
3、edef struct book3/*圖書借閱信息結(jié)構(gòu)體*/*需要輸入的信息*/char name20;char person20;char company20;char num20; /*借書證號(hào)*/char btime15;/*運(yùn)算可得信息*/char rtime15;char fine20;blend;/*圖書借閱信息:借閱人、借閱人所在單位、借書證號(hào)、所借書名、借閱日期、歸還日期、逾期罰款等。借閱期限為一個(gè)月,逾期1天,罰款1角。*/struct linklistbbasic binfo;struct linklist *next;int key();void menu();void
4、_window();void words();void box(int,int,int,int);int _choose(int bot, int top);void play(int);int readsum();void add();void addbook();void addbuy();void addborrow();void manage();struct linklist* create();void modify();void delete();void insert();void search();void searchname();void searchwriter();v
5、oid orderw(bbasic binfo100);void orderw(bbasic binfo100);int halfn(int sum,bbasic binfo100,char *find);int halfw(int sum,bbasic binfo100,char *find);void sta();void blist();void bmoney();int main(void)menu();void menu()int y;_window();/*顯示窗口*/words();/*顯示菜單文字*/y = choose(7,19);/*光標(biāo)*/play(y);/*根據(jù)鍵盤值操
6、作*/void _window()/*窗口初始化*/textbackground(BLUE);textcolor(WHITE);clrscr();box(1,1,24,80);void words()/*顯示菜單文字*/textcolor(WHITE);gotoxy(30,7);textbackground(RED);cprintf(Add Book info);textbackground(BLUE);gotoxy(30,10);cprintf(Manage Book);gotoxy(30,13);cprintf(Search Book);gotoxy(30,16);cprintf(Book
7、 Statistic);gotoxy(30,19);cprintf(Exit);gotoxy(35,22);textcolor(LIGHTGRAY);textbackground(BLUE);cprintf( Main Menu );gotoxy(25, 2);textcolor(RED);highvideo();cprintf(The Library Managemnt Program);normvideo();void box(int x,int y, int high, int width)/*畫方框*/int i;gotoxy(x,y);putchar(0xda);for (i = 1
8、 ; i width - 1; i+)putchar(0xc4);putchar(0xbf);gotoxy(x, y + high - 3);putchar(0xc0);gotoxy(width, y + high - 3);putchar(0xd9);for (i = 1; i high - 1; i+)gotoxy(x,y+i);putchar(0xb3);gotoxy(x + width -1, y+i);putchar(0xb3);gotoxy(x, y + high - 1);putchar(0xc0);for (i = 1 ; i width - 1; i+)putchar(0xc
9、4);gotoxy(x + 1, y + high - 3);for (i = 1; i bot)upbar(y);y = y - 3;break;case Key_DOWN:if (y top)downbar(y);y = y + 3;break;while(ky != Key_ENTER);return y;upbar(int y)/*光標(biāo)上移*/int i;typedef struct texel_structunsigned char ch;unsigned char attr;texel;texel t;for(i=30;i=48;i+)gettext(i,y,i,y,&t);t.a
10、ttr=0x1f;puttext(i,y,i,y,&t);gettext(i,y-3,i,y-3,&t);t.attr=0x4f;puttext(i,y-3,i,y-3,&t);gotoxy(30,y-3);return;downbar(int y)/*光標(biāo)下移*/int i;typedef struct texel_structunsigned char ch;unsigned char attr;texel;texel t;for(i=30;i=48;i+)gettext(i,y,i,y,&t);t.attr=0x1f;puttext(i,y,i,y,&t);gettext(i,y+3,i
11、,y+3,&t);t.attr=0x4f;puttext(i,y+3,i,y+3,&t);gotoxy(30,y+3);return;void play(int y) /*根據(jù)y的值選擇操作*/switch(y)case 7:add();break;case 10:manage();break;case 13:search();break;case 16:sta();break;case 19:exit(1);default:printf(Error);exit(0);void add() /*顯示 選擇增加那種類型的信息 的窗口*/int y;_window();gotoxy(30,7);t
12、extbackground(RED);cprintf(Add Basic info);textbackground(BLUE);gotoxy(30,10);cprintf(Add Purchase info);gotoxy(30,13);cprintf(Add Borrow info);gotoxy(30,16);cprintf(Back);gotoxy(25, 2);textcolor(RED);highvideo();cprintf(The Library Managemnt Program);normvideo();gotoxy(35,22);textcolor(LIGHTGRAY);t
13、extbackground(BLUE);cprintf( Add Book );textbackground(BLUE);textcolor(WHITE);y=choose(7,16);switch(y)/*選擇增加信息類型的函數(shù)*/case 7 :addbook();break;/*增加圖書基本信息*/case 10:addbuy();break;/*增加圖書購買信息*/case 13:addborrow();break;/*增加圖書借閱信息*/case 16:menu();break;default:printf(Error);break;void addbook()/*增加圖書基本信息*
14、/int ky, sum = 0;FILE *fp;bbasic binfo;textbackground(BLUE);textcolor(WHITE);clrscr();if(fp = fopen(e:sum.dat,rb) != NULL)/*讀取圖書基本信息數(shù)量sum*/fread(&sum,2,1,fp);fclose(fp);if (fp = fopen(e:addbook.dat,ab) = NULL)printf(cannot write the addbook.dat);doclrscr();gotoxy(2,2);cprintf(Please input the classf
15、ication of chinese library classification:);scanf(%s,&binfo.type);getchar();gotoxy(2,4);cprintf(Please input the books number:);scanf(%s,&binfo.num);getchar();gotoxy(2,6);cprintf(Please input the books name:);scanf(%s,&);getchar();gotoxy(2,8);cprintf(Please input the books writer:);scanf(%
16、s,&binfo.writer);getchar();gotoxy(2,10);cprintf(Please input the the books press:);scanf(%s,&binfo.press);getchar();gotoxy(2,12);cprintf(Please input the books edition:);scanf(%s,&binfo.edition);getchar();gotoxy(2,14);cprintf(Please input the books publish time:);scanf(%s,&binfo.time);getchar();goto
17、xy(2,16);cprintf(Please input the price:);scanf(%f,&binfo.price);getchar();gotoxy(2,18);cprintf(Please input the ISBN of the book:);scanf(%s,&binfo.ISBN);getchar();gotoxy(2,20);cprintf(Please input the count of books:);scanf(%d,&binfo.count);getchar();gotoxy(2,22);cprintf(Please input the lend numbe
18、r of the book:);scanf(%d,&binfo.lendnum);getchar();gotoxy(10,25);cprintf(Press N(n) to finish add book or Press any key to add more book.);ky = key();sum+;if(fwrite(&binfo,sizeof(bbasic),1,fp) != 1)clrscr();printf(cannot save the data.);while(ky != Key_N);fclose(fp);if (fp = fopen(e:sum.dat,wb) = NU
19、LL)printf(cannot save the sum of the book.);getch();exit(0);if(fwrite(&sum,2,1,fp) != 1)printf(fail to write the sum.dat.);getch();exit(0);fclose(fp);menu();/* 中圖法分類號(hào)、(要考慮多個(gè)作者情況)、出版社、出版日期、ISBN、版次、定價(jià)、館藏?cái)?shù)、借閱數(shù)等。 */void addbuy()/*增加圖書購買信息*/int ky;FILE *fp;bpurchase pinfo;textbackground(BLUE);textcolor(W
20、HITE);clrscr();if(fp = fopen(e:addbuy.dat,ab) = NULL)printf(cannot open the addbuy data.);exit(0);doclrscr();gotoxy(2,2);cprintf(Please input the books name:);scanf(%s,&);gotoxy(2,4);cprintf(Please input the books writer:);scanf(%s,&pinfo.writer);gotoxy(2,6);cprintf(Please input the books
21、buy time:);scanf(%s,&pinfo.writer);gotoxy(2,8);cprintf(Please input the number of the book buy:);scanf(%d,&pinfo.num);gotoxy(2,10);cprintf(Please input the price:);scanf(%f,&pinfo.price);gotoxy(2,12);cprintf(Please input the real money of buy the book:);scanf(%f, &pinfo.money);gotoxy(2,14);cprintf(P
22、lease input the bill number:);scanf(%s, &pinfo.bill);gotoxy(10,20);cprintf(Press N(n) to finish add book or Press any key to add more book.);ky = key();if(fwrite(&pinfo,sizeof(pinfo),1,fp) != 1)clrscr();printf(cannot save the data.);while(ky != Key_N);fclose(fp);menu();void addborrow()/*增加圖書借閱信息*/in
23、t ky;FILE *fp;blend linfo;textbackground(BLUE);textcolor(WHITE);clrscr();if(fp = fopen(e:addborrow.dat,ab) = NULL)printf(cannot open the addborrow data.);exit(0);doclrscr();gotoxy(2,2);cprintf(Please input the lend books name:);scanf(%s,&);gotoxy(2,4);cprintf(Please input the borrowers nam
24、e:);scanf(%s,&linfo.person);gotoxy(2,6);cprintf(Please input the company of the borrower:);scanf(%s,&pany);gotoxy(2,8);cprintf(Please input the borrowers card:);scanf(%s, &linfo.num);gotoxy(2,10);cprintf(Please input the borrow time(ex.2010/01/26):);scanf(%s, &linfo.btime);gotoxy(2,12);cpri
25、ntf(Please input the return time(ex.2010/05/08):);scanf(%s, &linfo.rtime);gotoxy(10,20);cprintf(Press N(n) to finish add book or Press any key to add more book.);ky = key();if(fwrite(&linfo,sizeof(linfo),1,fp) != 1)clrscr();printf(cannot save the data.);while(ky != Key_N);fclose(fp);menu();struct li
26、nklist* create() /*創(chuàng)建鏈表*/int i, sum;struct linklist *head, *p1, *p2;FILE *fp;sum = readsum();p1 = (struct linklist*)malloc(LEN);head = p2 = p1;if (fp = fopen(e:addbook.dat,rb) = NULL)printf(cannot open the file.);for (i = 0; i next = p1;if(fread(&(p2 - binfo),sizeof(bbasic),1,fp) != 1)printf(cannot
27、save the data.);p2 - next = NULL;fclose(fp);return head;void modify()struct linklist* p,*head;char find30;int i,ky,sum;FILE *fp;p= head = create();sum = readsum();clrscr();printf(Plese input the name of the book you want to modify:);scanf(%s,find);for (i = 0;i ) = 0)gotoxy(2,2);cprintf(Ple
28、ase input the classfication of chinese library classification:);scanf(%s,&(p - binfo.type);getchar();gotoxy(2,4);cprintf(Please input the books number:);scanf(%s,&(p - binfo.num);getchar();gotoxy(2,6);cprintf(Please input the books name:);scanf(%s,&(p - );getchar();gotoxy(2,8);cprintf(Plea
29、se input the books writer:);scanf(%s,&(p - binfo.writer);getchar();gotoxy(2,10);cprintf(Please input the the books press:);scanf(%s,&(p - binfo.press);getchar();gotoxy(2,12);cprintf(Please input the books edition:);scanf(%s,&(p - binfo.edition);getchar();gotoxy(2,14);cprintf(Please input the books p
30、ublish time:);scanf(%s,&(p - binfo.time);getchar();gotoxy(2,16);cprintf(Please input the price:);scanf(%f,&(p - binfo.price);getchar();gotoxy(2,18);cprintf(Please input the ISBN of the book:);scanf(%s,&(p - binfo.ISBN);getchar();gotoxy(2,20);cprintf(Please input the count of books:);scanf(%d,&(p - b
31、info.count);getchar();gotoxy(2,22);cprintf(Please input the lend number of the book:);scanf(%d,&(p - binfo.lendnum);getchar();printf(Press Y to continue or Press anykey to back to menu.);ky = key();if(ky = Key_Y)p = head;i = -1;clrscr();printf(Plese input the name of the book you want to modify:);sc
32、anf(%s,find);elsep = head;if (fp = fopen(e:addbook.dat,wb) = NULL)printf(cannot open addbook.dat);for (i = 0;i binfo),sizeof(bbasic),1,fp) != 1)clrscr();printf(cannot save the data.);p = p - next;fclose(fp);menu();p = p - next;clrscr();printf(cannot find the book.);getch();void delete()struct linkli
33、st* p1,*p2,*head;char find30;int i,ky,sum,flag = 0;FILE *fp;p1 = p2 = head = create();sum = readsum();clrscr();printf(Plese input the name of the book you want to Delete:);scanf(%s,find);if(strcmp(find,head - ) = 0)head = head -next;sum-;flag = 1;elsefor (i = 0;i next;if(strcmp(find,p1 - b
34、) = 0)p1 = p1 - next;p2 - next = p1;sum -;flag = 1;break;elsep2 = p2 - next;if (flag != 1)printf(cannot find the book.);getch();menu();p1 = head;if (fp = fopen(e:addbook.dat,wb) = NULL)printf(cannot open addbook.dat);for (i = 0;i binfo),sizeof(bbasic),1,fp) != 1)clrscr();printf(cannot save
35、the data.);p1 = p1 - next;fclose(fp);if(fp = fopen(e:sum.dat,wb) = NULL)printf(cannot open sum.dat);if(fwrite(&sum,2,1,fp) != 1)printf(fail to write the sum.dat.);getch();exit(0);fclose(fp);printf(succeed to delete the book.press anykey to get back to the mainmenu.);getch();void insert()struct linkl
36、ist* p1,*p2, *head, *temp;char find10;int i,ky,sum,flag = 0;FILE *fp;clrscr();sum = readsum();p1 = p2 = head = create();temp = (struct linklist*)malloc(LEN);printf(The number you want to insert behind:);scanf(%s,find);for(i = 0;inext;if(strcmp(find,p2 - binfo.num) = 0)p2 - next = temp;temp - next =p
37、1;sum +;flag = 1;break;elsep2 = p2-next;if (flag != 1)printf(cannot find the book.);getch();menu();clrscr();gotoxy(2,2);cprintf(Please input the classfication of chinese library classification:);scanf(%s,&(temp - binfo.type);getchar();gotoxy(2,4);cprintf(Please input the books number:);scanf(%s,&(te
38、mp - binfo.num);getchar();gotoxy(2,6);cprintf(Please input the books name:);scanf(%s,&(temp - );getchar();gotoxy(2,8);cprintf(Please input the books writer:);scanf(%s,&(temp - binfo.writer);getchar();gotoxy(2,10);cprintf(Please input the the books press:);scanf(%s,&(temp - binfo.press);get
39、char();gotoxy(2,12);cprintf(Please input the books edition:);scanf(%s,&(temp - binfo.edition);getchar();gotoxy(2,14);cprintf(Please input the books publish time:);scanf(%s,&(temp - binfo.time);getchar();gotoxy(2,16);cprintf(Please input the price:);scanf(%f,&(temp - binfo.price);getchar();gotoxy(2,1
40、8);cprintf(Please input the ISBN of the book:);scanf(%s,&(temp - binfo.ISBN);getchar();gotoxy(2,20);cprintf(Please input the count of books:);scanf(%d,&(temp - binfo.count);getchar();gotoxy(2,22);cprintf(Please input the lend number of the book:);scanf(%d,&(temp - binfo.lendnum);getchar();gotoxy(10,
41、25);cprintf(Press Y to continue or Press anykey to back to menu.);ky = key();if(ky = Key_Y)insert();elsep1 = head;if (fp = fopen(e:addbook.dat,wb) = NULL)printf(cannot open addbook.dat);for (i = 0;i binfo),sizeof(bbasic),1,fp) != 1)clrscr();printf(cannot save the data.);p1 = p1 - next;fclose(fp);if(
42、fp = fopen(e:sum.dat,wb) = NULL)printf(cannot open sum.dat);if(fwrite(&sum,2,1,fp) != 1)printf(fail to write the sum.dat.);getch();exit(0);fclose(fp);menu();void manage()/* 圖書管理 */int y;_window();gotoxy(30,7);textbackground(RED);cprintf(Modify Book);textbackground(BLUE);gotoxy(30,10);cprintf(Delete
43、Book);gotoxy(30,13);cprintf(Insert Book);gotoxy(30,16);cprintf(Back);gotoxy(25, 2);textcolor(RED);highvideo();cprintf(The Library Managemnt Program);normvideo();gotoxy(35,22);textcolor(LIGHTGRAY);textbackground(BLUE);cprintf( Manage Book );textbackground(BLUE);textcolor(WHITE);y=choose(7,16);switch(
44、y)case 7 :modify();menu();break;case 10:delete();menu();break;case 13:insert();menu();break;case 16:menu();default:printf(Error);break;void search()int y;_window();gotoxy(30,7);textbackground(RED);cprintf(Search by Name);textbackground(BLUE);gotoxy(30,10);cprintf(Search by Writer);gotoxy(30,13);cprint
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2026年灤鎮(zhèn)中心衛(wèi)生院招聘備考題庫完整參考答案詳解
- 2026年玉環(huán)市少年兒童業(yè)余體校關(guān)于招聘編外工作人員的備考題庫有答案詳解
- 2026年杭州市錢江灣小學(xué)招聘非編語文教師備考題庫完整答案詳解
- 2026年社招+校招四川省宜賓五糧液集團(tuán)進(jìn)出口有限公司公開招聘5人備考題庫及一套完整答案詳解
- 2026年郫都區(qū)中信大道幼兒園招聘教師備考題庫帶答案詳解
- 2026年濟(jì)南寶鋼鋼材加工配送有限公司招聘備考題庫含答案詳解
- 養(yǎng)老院入住老人遺愿實(shí)施與尊重制度
- 2026年派遣制阜陽市婦女兒童醫(yī)院人員招聘11人備考題庫及答案詳解參考
- 企業(yè)內(nèi)部保密工作責(zé)任追究制度
- 2025年醫(yī)療護(hù)理操作規(guī)范與質(zhì)量監(jiān)控指南
- 2026年托里國電投發(fā)電有限責(zé)任公司招聘備考題庫及1套完整答案詳解
- 2025-2026年魯教版八年級(jí)英語上冊期末真題試卷(+答案)
- 八年級(jí)下冊 第六單元寫作 負(fù)責(zé)任地表達(dá) 教學(xué)課件
- 26年三上語文期末密押卷含答題卡
- 2026屆云南省昆明市西山區(qū)民中數(shù)學(xué)高一上期末考試模擬試題含解析
- 2025年大學(xué)第一學(xué)年(食品營養(yǎng)與健康)營養(yǎng)學(xué)基礎(chǔ)測試題及答案
- 2025-2030烏干達(dá)基于咖啡的種植行業(yè)市場現(xiàn)狀供需分析及投資評(píng)估規(guī)劃分析研究報(bào)告
- 2026年共青團(tuán)中央所屬單位招聘66人備考題庫及答案詳解一套
- 人民警察法培訓(xùn)課件
- 小糖人課件:糖尿病患者兒童糖尿病的護(hù)理
- 2026年哈爾濱職業(yè)技術(shù)學(xué)院單招職業(yè)適應(yīng)性考試題庫參考答案詳解
評(píng)論
0/150
提交評(píng)論