版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
PAGEPAGE16高級(jí)語言程序設(shè)計(jì)(C)課程設(shè)計(jì)報(bào)告書目錄一、設(shè)計(jì)任務(wù)……(2)二、系統(tǒng)設(shè)計(jì)方案………………(3)三、程序主要代碼分析…………(4)四、程序調(diào)試中出現(xiàn)的問題及其解決方法…………………(17)五、改進(jìn)意見與收獲體會(huì)………(18)六、主要參考資料………………(18)附:此設(shè)計(jì)經(jīng)過多次修改,但還存在一些不足的地方,希望老師多多指點(diǎn)。設(shè)計(jì)任務(wù)設(shè)計(jì)題目:圖書信息管理系統(tǒng)設(shè)計(jì)圖書信息包括:登錄號(hào)、書名、作者名、分類號(hào)、出版單位、出版時(shí)間、價(jià)格等。試設(shè)計(jì)一圖書管理系統(tǒng),使之能提供以下功能:系統(tǒng)以菜單方式工作;圖書信息錄入功能;(圖書信息用文件保存)——輸入;圖書信息瀏覽功能——輸出;查詢和排序功能:——算法按書名查詢按作者名查詢圖書信息的刪除和修改。整個(gè)系統(tǒng)均用C語言實(shí)現(xiàn);可以利用數(shù)組、指針、鏈表來實(shí)現(xiàn)數(shù)據(jù)結(jié)構(gòu)設(shè)計(jì);系統(tǒng)具有輸入、顯示、查詢、刪除、排序、插入、保存、讀取等基本功能;可以將信息保存在文件中;可以將信息從文件中讀取出來。報(bào)告要求:簡(jiǎn)述本項(xiàng)課程設(shè)計(jì)要解決的問題,主要的設(shè)計(jì)思想,劃分功能模塊,畫出各模塊的結(jié)構(gòu)流程圖。列出每個(gè)函數(shù)的聲明、功能、調(diào)用參數(shù)及函數(shù)之間的調(diào)用關(guān)系。記錄調(diào)試過程中出現(xiàn)的問題及解決的方法。系統(tǒng)設(shè)計(jì)方案顯示記錄顯示記錄按編號(hào)大小排序排序顯示記錄查詢記錄添加記錄按書名排序按價(jià)格大小排序按人名排序按出版時(shí)間排序按分類排序按書名查詢按人名查詢修改無操作刪除保存添加記錄保存圖書信息管理系統(tǒng)模塊一:排序顯示記錄——1Sort();2Disp();模塊二:查詢記錄——3Qur();4Modify();5Del();Save();模塊三:添加記錄——6Add();7Save();本程序主要有七大功能——排序、顯示、查詢、修改、刪除、添加、保存記錄。根據(jù)我們?nèi)粘J褂昧?xí)慣,我將它們劃分為三個(gè)主要模塊(如上顯示)。程序主要代碼分析//預(yù)處理程序//#include"stdio.h"#include"stdlib.h"http://標(biāo)準(zhǔn)函數(shù)庫(kù)//#include"string.h"#include"conio.h"http://屏幕操作函數(shù)庫(kù)//#defineFORMAT"|%-10s|%-15s|%-15s|%-6s|%-10s|%-10s|%-6s|\n"#defineDATAp->num,p->bkname,p->author,p->classi,p->pub,p->pubdate,p->price#defineHEADER2"________________________________________________________________________________\n"#defineHEADER3"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"intcount=0;typedefstructbookinfor{ charnum[10]; charbkname[15]; charauthor[15]; charclassi[6]; charpub[10]; charpubdate[10]; charprice[6];}BOOK;//主菜單界面menu()//voidmenu(){ system("cls"); printf("\n\n\n\nHELLO!!WELCOMETOTHEBOOKINFORMATIONMANAGEMENTSYSTEM!**^-^**\n"); printf("\n\n\nTHEBOOKINFORMATIONMANAGEMENTSYSTEM\n"); printf("\n\n************************************************************************\n"); printf("**\n"); printf("*1.sortdisprecord2.searchrecord*\n"); printf("**\n"); printf("*3.addrecord0.quitrecord*\n"); printf("**\n"); printf("************************************************************************\n"); printf("\nmeitong091--HuangXiaomei--208090410\n"); printf("\n");}//表格形式顯示記錄//voidprintheader(){ system("cls"); printf("\n\nBOOKINFORMATION\n"); printf(HEADER2); printf(FORMAT,"Num","Bookname","Author","Classi","Pubhouse","Pubdate","Price"); printf(HEADER2);}voidprintdata(BOOKpp){ BOOK*p; p=&pp; printf(FORMAT,DATA);}//查找定位//intLocate(BOOKtemp[],intn,charfindmess[],charbkorauthor[]){ inti=0; if(strcmp(bkorauthor,"bkname")==0) { while(i<n) { if(strcmp(temp[i].bkname,findmess)==0) returni; } } else if(strcmp(bkorauthor,"author")==0) { while(i<n) { if(strcmp(temp[i].author,"findmess")==0) returni; i++; } } return-1;}//提示信息//voidWrong(){ system("cls"); printf("\n\n\n\n\n*******************ERROR:INPUTHASWRONG!*****************************\n"); printf("Pressanykeytocontinue\n");}voidNofind(){ system("cls"); printf("\n\n\n\n\n*******************DON'TFINDTHEBOOKINFORMATIONRECORD!*****************************\npressanykeytoreturn..."); getchar(); return;}//格式化輸入數(shù)據(jù)stringinput(```)//voidstringinput(char*t,intlens,char*noice){ charn[255]; do{ printf(noice); scanf("%s",n); if(strlen(n)>lens) printf("\n\nEXCCEDTHEREQUIREDLENGTH!\n"); }while(strlen(n)>lens); strcpy(t,n);}//OK!!操作7//voidSave(BOOKqq[],intm){ FILE*fp; inti=0; system("cls"); fp=fopen("d:\\bookmanage","w"); if(fp==NULL) { printf("\n\n=======>OPENFILEERROR!\n"); return; } for(i=0;i<m;i++) { if(fwrite(&qq[i],sizeof(BOOK),1,fp)==1) continue; else break; } printf("\n\n=======>SAVEFILECOMPLETE!TOTALSAVEDRECORDNUMBERIS:%d\n",i); fclose(fp);}//操作2//voidDisp(BOOKpp[],intm){ inti; BOOK*p; if(m==0) { printf("\n************NOBOOKINFORMATIONRECORD!***************\n"); return; } printf("\n\nBOOKINFORMATION\n"); printf(HEADER2); printf(FORMAT,"Num","Bookname","Author","Classi","Pubhouse","Pubdate","Price"); printf(HEADER3); i=0; while(i<m) { p=&pp[i]; printf(FORMAT,DATA); i++; printf(HEADER3); }}//操作1//voidSort(BOOKtemp[],intn){ intx; intindexmin,i,j,flag=0; BOOKnewinfo; system("cls"); printf("\n\n##############SEARCHFORTHERECORD##############\n"); if(n<=0) { Nofind(); return; } printf("\nPleasechoosethewayofdisplayingtherecord:(o-6)\n"); printf("=====>1.displaybynum2.displaybybkname3.displaybyauthor\n4.dispalybyclassi5.displaybypubdate6.dispalybyprice\n0.returnthemenu\nPleaseenteryourchoice:"); scanf("%d",x); if(x==0) { return; } if(x==1) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].num);//atoi(temp[j].num)函數(shù)將字符型數(shù)據(jù)轉(zhuǎn)換為整型數(shù)據(jù)// indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].num)<flag) { flag=atoi(temp[j].num); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } if(x==2) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].bkname);//atoi(temp[j].num)函數(shù)將字符型數(shù)據(jù)轉(zhuǎn)換為整型數(shù)據(jù)// indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].bkname)<flag) { flag=atoi(temp[j].bkname); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } if(x==3) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].author);//atoi(temp[j].num)函數(shù)將字符型數(shù)據(jù)轉(zhuǎn)換為整型數(shù)據(jù)// indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].author)<flag) { flag=atoi(temp[j].author); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } if(x==4) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].classi);//atoi(temp[j].num)函數(shù)將字符型數(shù)據(jù)轉(zhuǎn)換為整型數(shù)據(jù)// indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].classi)<flag) { flag=atoi(temp[j].classi); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } if(x==5) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].pubdate);//atoi(temp[j].num)函數(shù)將字符型數(shù)據(jù)轉(zhuǎn)換為整型數(shù)據(jù)// indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].pubdate)<flag) { flag=atoi(temp[j].pubdate); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } if(x==6) { for(i=0;i<n-1;i++) { flag=atoi(temp[0].price); indexmin=0; for(j=i;j<n;j++) { if(atoi(temp[j].price)<flag) { flag=atoi(temp[j].price); indexmin=j; } } strcpy(newinfo.num,temp[i].num); strcpy(newinfo.bkname,temp[i].bkname); strcpy(newinfo.author,temp[i].author); strcpy(newinfo.classi,temp[i].classi); strcpy(newinfo.pub,temp[i].pub); strcpy(newinfo.pubdate,temp[i].pubdate); strcpy(newinfo.price,temp[i].price); strcpy(temp[i].num,temp[indexmin].num); strcpy(temp[i].bkname,temp[indexmin].bkname); strcpy(temp[i].author,temp[indexmin].author); strcpy(temp[i].classi,temp[indexmin].classi); strcpy(temp[i].pub,temp[indexmin].pub); strcpy(temp[i].pubdate,temp[indexmin].pubdate); strcpy(temp[i].price,temp[indexmin].price); strcpy(temp[indexmin].num,newinfo.num); strcpy(temp[indexmin].bkname,newinfo.bkname); strcpy(temp[indexmin].author,newinfo.author); strcpy(temp[indexmin].classi,newinfo.classi); strcpy(temp[indexmin].pub,newinfo.pub); strcpy(temp[indexmin].pubdate,newinfo.pubdate); strcpy(temp[indexmin].price,newinfo.price); } } Disp(temp,n); return;}//OK操作4//voidModify(BOOKpp[],intm){ printf("Number:%d,\n",pp[m].num); printf("Name:%s,\n",pp[m].bkname); stringinput(pp[m].bkname,15,"inputnewbookname:\n"); printf("Author:%s,\n",pp[m].author); stringinput(pp[m].author,15,"inputnewauthor'sname:\n"); printf("Classification:%s,\n",pp[m].classi); stringinput(pp[m].classi,6,"inputnewclassi:\n"); printf("Pub:%s,\n",pp[m].pub); stringinput(pp[m].pub,10,"inputnewpub:\n"); printf("Pubdate:%s,\n",pp[m].pubdate); stringinput(pp[m].pubdate,10,"inputnewpubdate:\n"); printf("Price:%s,\n",pp[m].price); stringinput(pp[m].price,6,"inputnewprice:\n"); printf("=======>MODIFYSUCCESS!!\nThenewrecord:\n"); printheader(); printdata(pp[m]); printf(HEADER3); printf("\npressanykeytocontinue"); return;}//ok操作5//voidDel(BOOKpp[],intm,inth){ inti; for(i=h+1;i<m;i++) { strcpy(pp[i-1].bkname,pp[i].bkname); strcpy(pp[i-1].author,pp[i].author); strcpy(pp[i-1].classi,pp[i].classi); strcpy(pp[i-1].pub,pp[i].pub); strcpy(pp[i-1].pubdate,pp[i].pubdate); strcpy(pp[i-1].price,pp[i].price); } printf("\n=======>DELETESUCCESS!!\n"); m--; count=m; return;}//ok操作3//voidQur(BOOKtemp[],intn){ intselect_1,select_2; charsearchinput[20]; intp=0; system("cls"); printf("\n\n##############SEARCHFORTHERECORD##############\n"); if(n<=0) { printf("\n\n********NOBOOKINFORMATIONRECORD!*********\n"); return; } printf("\n\n========>1.Searchbybookname2.Searchbyauthor\n"); printf("Pleasechoose[1,2]:"); scanf("%d",&select_1); if(select_1==1) { stringinput(searchinput,15,"inputtheexistingbookname:"); p=Locate(temp,n,searchinput,"bkname"); if(p!=-1) { printheader(); printdata(temp[p]); printf(HEADER3); printf("\npressanykeytocontinue"); } else { Nofind(); } } else if(select_1==2) { stringinput(searchinput,15,"inputtheexistingauthor'sname:"); p=Locate(temp,n,searchinput,"author"); if(p!=-1) { printheader(); printdata(temp[p]); printf(HEADER3); printf("\npressanykeytocontinue"); getchar(); } else { Nofind(); } } else Wrong(); printf("Doyouwanttomodifyordeletetherecord?"); printf("=====>1.modify2.delete3.returnthemenu\nPleasegiveyourchice(1/2/3):"); scanf("%d",select_2); switch(select_2) { case1:Modify(temp,p);Save(temp,n);break; case2:Del(temp,n,p);Save(temp,n);break; case3:break; default:Wrong();break; }}//操作6//intAdd(BOOKtemp[],intn){ charch,num[10]; inti,flag=0; system("cls"); printf("\n\n##############ADDRECORD##############\n"); while(1) { while(1) { stringinput(num,10,"inputanumber(press'0'returnmenu):"); flag=0; if(strcmp(num,"0")==0) returnn; i=0; while(i<n) { if(strcmp(temp[i].num,num)==0) { flag=1; break; } i++; } if(flag==1) { printf("\n\n==>Thenumber%sisexisting,tryagain?(y/n):",num); scanf("%c",&ch); if(ch=='y'||ch=='Y') continue; else returnn; } else break; } strcpy(temp[n].num,num); stringinput(temp[n].bkname,15,"Bookname:"); stringinput(temp[n].author,15,"Author:"); stringinput(temp[n].classi,6,"Classification:"); stringinput(temp[n].pub,10,"Publishinghouse:"); stringinput(temp[n].pubdate,10,"Pubdate:");
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 清潔工程智能化施工合同
- 醫(yī)療機(jī)構(gòu)質(zhì)量管理與合規(guī)
- 工業(yè)園區(qū)道路級(jí)配碎石鋪設(shè)協(xié)議
- 居民燃?xì)馐褂弥笇?dǎo)手冊(cè)
- 苗木花卉買賣合同范本
- 電力公司解除聘用合同說明
- 寫字樓交易合同范本
- 水果市場(chǎng)裝卸人員聘用合同
- 航空垃圾特種管理辦法
- 藥品行業(yè)自律規(guī)范要求
- 2024版影視制作公司與演員經(jīng)紀(jì)公司合作協(xié)議3篇
- 新疆大學(xué)答辯模板課件模板
- 數(shù)值分析智慧樹知到期末考試答案2024年
- (正式版)HGT 22820-2024 化工安全儀表系統(tǒng)工程設(shè)計(jì)規(guī)范
- 2024年浙江省新華書店集團(tuán)招聘筆試參考題庫(kù)附帶答案詳解
- 跨文化溝通心理學(xué)智慧樹知到期末考試答案2024年
- 《中華民族共同體概論》考試復(fù)習(xí)題庫(kù)(含答案)
- 【綠色評(píng)價(jià)】發(fā)展綠色指標(biāo)評(píng)價(jià)測(cè)試五年級(jí)《英語》第一學(xué)期上冊(cè)期末試卷及答案解析
- 預(yù)制梁場(chǎng)建設(shè)驗(yàn)收標(biāo)準(zhǔn)
- 物理電學(xué)暗箱專題30道
- 三國(guó)志11武將出場(chǎng)時(shí)間地點(diǎn)整理
評(píng)論
0/150
提交評(píng)論