版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
PAGEPAGE16高級語言程序設(shè)計(C)課程設(shè)計報告書目錄一、設(shè)計任務(wù)……(2)二、系統(tǒng)設(shè)計方案………………(3)三、程序主要代碼分析…………(4)四、程序調(diào)試中出現(xiàn)的問題及其解決方法…………………(17)五、改進(jìn)意見與收獲體會………(18)六、主要參考資料………………(18)附:此設(shè)計經(jīng)過多次修改,但還存在一些不足的地方,希望老師多多指點。設(shè)計任務(wù)設(shè)計題目:圖書信息管理系統(tǒng)設(shè)計圖書信息包括:登錄號、書名、作者名、分類號、出版單位、出版時間、價格等。試設(shè)計一圖書管理系統(tǒng),使之能提供以下功能:系統(tǒng)以菜單方式工作;圖書信息錄入功能;(圖書信息用文件保存)——輸入;圖書信息瀏覽功能——輸出;查詢和排序功能:——算法按書名查詢按作者名查詢圖書信息的刪除和修改。整個系統(tǒng)均用C語言實現(xiàn);可以利用數(shù)組、指針、鏈表來實現(xiàn)數(shù)據(jù)結(jié)構(gòu)設(shè)計;系統(tǒng)具有輸入、顯示、查詢、刪除、排序、插入、保存、讀取等基本功能;可以將信息保存在文件中;可以將信息從文件中讀取出來。報告要求:簡述本項課程設(shè)計要解決的問題,主要的設(shè)計思想,劃分功能模塊,畫出各模塊的結(jié)構(gòu)流程圖。列出每個函數(shù)的聲明、功能、調(diào)用參數(shù)及函數(shù)之間的調(diào)用關(guān)系。記錄調(diào)試過程中出現(xiàn)的問題及解決的方法。系統(tǒng)設(shè)計方案顯示記錄顯示記錄按編號大小排序排序顯示記錄查詢記錄添加記錄按書名排序按價格大小排序按人名排序按出版時間排序按分類排序按書名查詢按人名查詢修改無操作刪除保存添加記錄保存圖書信息管理系統(tǒng)模塊一:排序顯示記錄——1Sort();2Disp();模塊二:查詢記錄——3Qur();4Modify();5Del();Save();模塊三:添加記錄——6Add();7Save();本程序主要有七大功能——排序、顯示、查詢、修改、刪除、添加、保存記錄。根據(jù)我們?nèi)粘J褂昧?xí)慣,我將它們劃分為三個主要模塊(如上顯示)。程序主要代碼分析//預(yù)處理程序//#include"stdio.h"#include"stdlib.h"http://標(biāo)準(zhǔn)函數(shù)庫//#include"string.h"#include"conio.h"http://屏幕操作函數(shù)庫//#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等.壓縮文件請下載最新的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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 受資助學(xué)生典型事跡材料范文(14篇)
- 《天體物理學(xué)時間》課件
- 文物數(shù)字化與5G技術(shù)應(yīng)用-洞察分析
- 微笑線與年齡相關(guān)性-洞察分析
- 栓子催化技術(shù)進(jìn)展-洞察分析
- 勤儉節(jié)約先進(jìn)事跡材料(范文8篇)
- 網(wǎng)絡(luò)拓?fù)溲莼治?洞察分析
- 消費者價值共創(chuàng)研究-洞察分析
- 營銷組合策略在批發(fā)零售中的應(yīng)用-洞察分析
- 醫(yī)療保險個人工作總結(jié)(5篇)
- 青年應(yīng)有鴻鵠志當(dāng)騎駿馬踏平川課件高三上學(xué)期勵志主題班會
- 河北省唐山市2021-2022學(xué)年高三上學(xué)期語文期末試卷
- 華電甘肅能源有限公司華電系統(tǒng)內(nèi)外招聘真題
- 員工宿舍管理條例
- 2024應(yīng)急預(yù)案編制導(dǎo)則
- 江蘇省徐州市2023-2024學(xué)年高一上學(xué)期1月期末抽測試題 生物 含解析
- Unit 1 You and Me Section B (1a~1d) 說課稿 2024-2025學(xué)年人教版(2024)七年級英語上冊
- 園林灌溉施工合同范例
- 數(shù)值分析智慧樹知到期末考試答案2024年
- 跨文化溝通心理學(xué)智慧樹知到期末考試答案2024年
- 伯努利方程逐段試算法求水庫回水
評論
0/150
提交評論