




版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、儀器儀表管理1.題目要求.【要求】 系統功能的基本要求:(1) 新的儀器儀表信息的錄入;(2) 在借出、歸還、維修時對儀器儀表信息的修改;(3) 對報廢儀器儀表信息的刪除;(4) 按照一定的條件查詢符合條件的儀器儀表信息;查詢功能至少應該包括儀器儀表基本信息(如儀器儀表名字、儀器儀表編等)的查詢、按時間點(借入時間、借出時間、歸還時間)查詢等(5) 對查詢結果的輸出。 【提示】 數據結構采用結構體。儀器儀表信息包括儀器儀表名、儀器儀表編號、購買時間、借入時間、借出時間、歸還時間、維修時間、狀態信息(0代表可借出,1代表已借出,2代表正在維修)等。.需求分析根據題目要求,需要把儀器儀表信息的的數
2、據存儲在文件里,所以需要提供文件的輸入輸出等操作;在程序中要提供修改,刪除,查找等操作;另外還應該提供鍵盤式選擇菜單實現功能選擇。2.功能實現設計2.1總體設計 儀器儀表管理系統添加查詢修改刪除退出系統功能模塊圖2.2詳細設計1. 主函數主函數一般設計得比較簡潔,只提供輸入輸出和功能處理的函數調用。其各功能模塊用菜單方式選擇。本題將main()函數體內的界面選擇部分語句單獨抽取出來作為一獨立函數,目的在于系統執行完每部分功能模塊后能夠方便返回到系統界面。【程序】 main()menu();菜單部分設計如下:【流程圖】顯示一系列功能選項 輸入n,判斷n是否是17 N Y根據n的值調用各功能模塊函
3、數 主函數的菜單流程圖【程序】main()system("cls");/*清屏*/menu();void menu()int w,n;dosystem("cls");printf("tt WELCOME TO THE EQUIPMENT MANAGEMENT SYSTEMnnn");printf("nntt=*=nnn");printf("ttt1:Add message of new equipmennn");printf("ttt2:Load the message of all
4、equipmentnn");printf("ttt3:Correct the message of equipmentnn");printf("ttt4:Ddlete the message of broken equipmentnn");printf("ttt5:Search the message of equipmentnn");printf("ttt6:Search of all the equipmentnn");printf("ttt7:Exitn");printf(&qu
5、ot;nntt=*=nnn");printf("Please choice your number: bb");scanf("%d",&n);if(n<1|n>7) w=1;else w=0;while (w=1);/*選擇功能*/switch(n)case 1:add_new_message();break;/*添加模塊*/case 2:load_record();break;/*顯示模塊*/case 3:modify();break;/*修改模塊*/case 4:delete();break;/*刪除模塊*/case 5
6、:search();break;/*查詢模塊*/case 6:statistic();break;/*統計模塊*/case 7:exit(0);break;/*退出模塊*/2. 各功能模塊設計(1)添加模塊 【數據結構】 【分析】 單獨看各數據信息,儀器儀表名是字符型,可采用字符型數組;儀器儀表編號、購買時間、借入時間、借出時間、歸還時間、維修時間應采用實型;狀態信息是整數,采用整型。實際上操作時發現只有字符型的數據可以在文件中成功被保存,所以本題所有數據一律采用字符型。struct equipchar number4;char name11;char b_time11;char bin_ti
7、me11;char bout_time11;char giveb_time11;char repair_time11; /*time為下面程序中按時間查找和修改時記錄輸入的時間*/int state;equM;【注意】equM中的M是儀表儀器個數,程序中采用宏定義的方式,可以隨時在源程序宏定義中改,本程序宏定義#define M 50。輸入用戶要輸入儀器的個數n 【流程圖】i從0到n1調用輸入函數input(i) i!0 Y調用保存函數save(n)輸入模塊流程圖【程序】/*添加模塊*/void add_new_message()int t,i,m;system("cls"
8、);t=load_equ();printf("How many groups datas do you want to add?n");printf("input the number: bbb");scanf("%d",&m);for(i=0;i<m;i+)printf("nInput %dth equipment record.n",i+1);input(t+i);/*調用輸入函數*/save(t+m,0);/*調用保存函數 保存t+m組數據*/system("cls");me
9、nu();/*返回登陸界面*/*輸入函數*/ void input(int i)printf("Please input:nnumber name b_time b_in_time b_out_time g_back_time repair_time staten");scanf("%s %s %s %s %s %s %s %d",&equi.number,&,&equi.b_time,&equi.bin_time,&equi.bout_time,&equi.giveb_time,&
10、;equi.repair_time,&equi.state);/*顯示記錄模塊*/void load_record()int t;t=load_equ();printf_n(t);printf("nnnPress any key to go back.nn");getchar();menu();/*顯示一個儀器記錄的函數*/void printf_one(int i)printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn",equi.number,,equi.b_time,e
11、qui.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);/*顯示n個儀器記錄的函數*/void printf_n(int n)int j;system("cls");/*清屏*/printf("number name b_time b_in_time b_out_time g_back_time repair_time sn");for(j=0;j<n;j+) if(j+1)%10=0)/*控制顯示,每屏顯示10行*/ printf("nnPass
12、any key to continue ."); getchar(); puts("nn"); printf_one(j);/*調用顯示一個儀器記錄的函數*/ (2)修改模塊需求分析 該模塊的功能是顯示所有儀器儀表信息,考慮到記錄較多,建議采用分屏顯示。顯示完所有記錄后,用戶輸入要修改的儀器儀表編號,根據編號查找儀器儀表記錄,并提示用戶修改該記錄的哪部分信息,是儀器儀表的借出時間、歸還時間、修理時間還是狀態,根據用戶選擇修改相應信息。讓用戶選擇查詢方式(number or name)流程圖輸入number or name是否找到此記錄 Y N顯示找到的記錄,調用修
13、改函數提示沒有找到 返回主菜單詢問用戶是否繼續修改修改模塊流程圖程序/*修改模塊*/void modify()struct equip mod;int t,i,m,w,addr=-1;char number4=' ', name11=' 'system("cls");/*清屏*/t=load_equ();doprintf("nInput the equipment'number or name ( 1:the number 2:the name ):nn");printf("What is your ch
14、oice: bb");scanf("%d",&m);if(m=1|m=2) w=0;else w=1;while(w=1);switch(m) case 1: printf("nnPlease input the equipment's number:_bbbb"); scanf("%s",number);break; case 2: printf("Please input the equipment's name:_bbbbbbbbbbb"); scanf("%s&q
15、uot;,name);break;for(i=0;i<t;i+)/*查找要修改的儀器*/ if(strcmp(,name)=0|strcmp(equi.number,number)=0) addr=i; printf("nnPlease input the new information:nn"); printf("number name b_time b_in_time b_out_time g_back_time repair_time sn"); scanf("%s%s%s%s%s%s%s%d",mod.
16、number,,mod.b_time,mod.bin_time,mod.bout_time,mod.giveb_time,mod.repair_time,&mod.state); strcpy(equi.number,mod.number);strcpy(,);strcpy(equi.b_time,mod.b_time);strcpy(equi.bin_time,mod.bin_time);strcpy(equi.bout_time,mod.bout_time); strcpy(equi.giveb_time,mod.giveb_tim
17、e);strcpy(equi.repair_time,mod.repair_time); equi.state=mod.state;printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn",equi.number,,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);break; if(addr=-1) printf(" Cannot find the equipment w
18、hich you want to modify!nn");printf(" Press any key to go back.nn"); getchar(); menu(); save(t,0);/*修改后的信息保存*/printf(" Press any key to go back.nn");getchar();menu();(3)查詢模塊顯示一系列功能選項流程圖輸入n,判斷n是否是1-4 N Y根據n的值調用各子功能模塊函數查詢模塊流程圖程序 /*查詢模塊*/void search()int w,n;dosystem("cls&
19、quot;);printf("ntt*nn");printf("ttby b_time quantum to search? Input1n");printf("ttby give_back_time quantum to search? Input2n");printf("ttby number to search? Input3n");printf("ttby name to search? Input4n");printf("tt*nn");printf("
20、Choice your number(1-4): bbb");scanf("%d",&n);if(n<1|n>4) w=1;else w=0;while (w=1);/*選擇功能*/switch(n)case 1:sb_buy_tq();break;/*按購買時間段查詢函數*/case 2:sb_gb_tq();break;/*按歸還時間段查詢*/case 3:sb_par_number();break;/*按指定編號查詢*/case 4:sb_name();break;/*按儀器名稱查詢*/void sb_buy_tq()/*按購買時間段查詢
21、函數*/ char year111,year211; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the start time:_._._bbbbbbbbbbb"); scanf("%s",year1); printf("n"); printf("Please input the finish time:_._._bbbbbbbbbbb"); scanf("%s",year2); print
22、f("n"); system("cls"); for(i=0;i<t;i+) if(strcmp(equi.b_time,year1)>=0)&&(strcmp(equi.b_time,year2)<=0) printf_one(i);/*把符合條件的記錄顯示出來*/ sum+; save_search_record(i);/*把符合條件的記錄保存在查詢記事本里*/ getch(); if(sum=0) system("cls"); printf("Sorry! Cannot find th
23、e equipment which you want to.nn"); getch(); printf("Press any key to go back the former step.n"); getchar(); menu();void sb_gb_tq()/*按購買時間段查詢函數*/char year111,year211;int t,i,sum=0;t=load_equ();system("cls");printf("Please input the start time:_._._bbbbbbbbbbb");sc
24、anf("%s",year1);printf("n");printf("Please input the finish time:_._._bbbbbbbbbbb");scanf("%s",year2);printf("n");system("cls"); for(i=0;i<t;i+) if(strcmp(equi.giveb_time,year1)>=0)&&(strcmp(equi.b_time,year2)<=0) printf_on
25、e(i);/*把符合條件的記錄顯示出來*/ sum+; save_search_record(i);/*把符合條件的記錄保存在查詢記事本里*/ getch(); if(sum=0) system("cls"); printf("*nn"); printf("Sorry! Cannot find the equipment which you want to.nn"); printf("*nn"); getch(); printf("Press any key to go back the former s
26、tep.n"); getchar(); menu();void sb_par_number()/*按指定編號查詢*/char number4;int t,i,sum=0;t=load_equ();system("cls");printf("Please input the equipment number(000999):_bbbb");scanf("%s",number);printf("n"); system("cls"); for(i=0;i<t;i+) if(strcmp
27、(equi.number,number)=0) printf_one(i);/*把符合條件的記錄顯示出來*/ sum+; save_search_record(i);/*把符合條件的記錄保存在查詢記事本里*/ getch(); if(sum=0) system("cls"); printf("Sorry! Cannot find the equipment which you want to.nn"); getch(); printf("Press any key to go back the former step.n"); get
28、char(); menu();void sb_name()/*按儀器名稱查詢*/char name11;int t,i,sum=0;t=load_equ();system("cls");printf("Please input the equipment name:_bbbbbbbbbbb");scanf("%s",name);printf("n");system("cls"); for(i=0;i<t;i+) if(strcmp(,name)=0) printf_one
29、(i);/*把符合條件的記錄顯示出來*/ sum+; save_search_record(i);/*把符合條件的記錄保存在查詢記事本里*/ getch(); if(sum=0) system("cls"); printf("Sorry! Cannot find the equipment which you want to.nn"); getch(); printf("Press any key to go back the former step.n"); getchar(); menu();(4)刪除模塊需求分析 該模塊的功能與
30、修改模塊一樣先顯示所有儀器儀表信息,同樣考慮到記錄較多,建議采用分屏顯示。顯示完所有記錄后,用戶輸入要修改的儀器儀表編號,根據編號查找儀器儀表記錄,并提示用戶是否確定要刪除。讓用戶選擇如何搜尋記錄(by number or by name)流程圖輸入要刪除的儀器編號或名稱是否找到此記錄 Y N顯示找到的記錄提示沒有找到刪除 并保存未刪除的記錄刪除 保存為刪除的記 返回主菜單刪除模塊流程圖程序 /*刪除模塊*/3. void delete1()4. 5. FILE *fp1;6. /struct equip mod;7. int t,i,m,w,addr=-1;8. char number4=&
31、#39; ', name11=' '9. /char a12,a22;10. system("cls");/*清屏*/11. t=load_equ();12. if(fp1=fopen("record.txt","w")=NULL)/*以只寫方式打開*/13. 14. printf("nCannot open filen");15. exit(0);16. 17. system("cls");18. do19. 20. system("cls");21
32、. printf("nPlease Input the equipment'number or name to find it( 1:the number 2:the name ):nn");22. printf("What is your choice: bb");23. scanf("%d",&m);24. if(m=1|m=2)25. w=0;26. else27. w=1;28. while(w=1);29.30. switch(m)31. 32. case 1:33. printf("nnPleas
33、e input the equipment's number:(_)bbbb");34. scanf("%s",number);break;35. case 2:36. printf("Please input the equipment's name:(_)bbbbbbbbbbb");37. scanf("%s",name);break;38. 39.40. for(i=0;i<t;i+)/*查找要刪除的儀器*/41. 42. if(strcmp(,name)=0|strcmp(eq
34、ui.number,number)=0)43. 44. addr=i;45. system("cls");46. printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn",equi.number,,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state); getch(); system("cls");printf("Congratunati
35、ons ! You have been successful to delete it's information. _n"); getch();continue;fwrite(&equi,sizeof(struct equip),1,fp1);/*把不想刪除的保存在記事本里,想刪除的不保存即為刪除*/fclose(fp1);/*關閉文件*/if(addr=-1) system("cls");printf(" Cannot find the equipment which you want to delete!nn");getc
36、h(); printf(" nnnPress any key to go back.nn");getchar();menu();(6) 統計模塊 按要求可按時間段統計 按基本信息統計 并保存至統計記錄文檔 流程圖類似查詢模塊/*統計模塊*/ void statistic()int w,n;dosystem("cls");printf("ntt*nn");printf("ttby b_time quantum to statistic? Input1n");printf("ttby give_back_ti
37、me quantum to statistic? Input2n");printf("ttby number to statistic? Input3n");printf("ttby name to statistic? Input4n");printf("tt*nn");printf(" Choice your number(1-4): bbb");scanf("%d",&n);if(n<1|n>4) w=1;else w=0;while (w=1);/*選擇功能
38、*/switch(n)case 3:tb_par_number();break;case 4:tb_name();break;case 1:tb_buy_tq();break;case 2:tb_gb_tq();break;void tb_par_number()char number4;int t,i,sum=0;t=load_equ();system("cls");printf("Please input the equipment number(000999):_bbbb");scanf("%s",number);printf(
39、"n"); for(i=0;i<t;i+) if(strcmp(equi.number,number)=0) sum+; save_statistic_record(i);/*把符合條件的記錄保存在查詢記事本里*/ if(sum=0) system("cls"); printf(" Sorry! Cannot find the equipment which you want to!nn"); getch(); else system("cls");printf(" There are%-2dequ
40、ipment(s) which you want to statistic in the record!nn",sum);getch(); printf("Press any key to go back the former step.n"); getchar(); menu();void tb_name()char name11;int t,i,sum=0;t=load_equ();system("cls");printf("Please input the equipment name:_bbbbbbbbbbb");s
41、canf("%s",name);printf("n"); for(i=0;i<t;i+) if(strcmp(,name)=0) sum+; save_statistic_record(i);/*把符合條件的記錄保存在查詢記事本里*/ if(sum=0) system("cls");printf(" Sorry! Cannot find the equipment which you want to!nn");getch(); else system("cls");pri
42、ntf(" There are%-2dequipment(s) which you want to statistic in the record!nn",sum);getch(); printf("Press any key to go back the former step.n"); getchar(); menu();void tb_buy_tq()char year111,year211;int t,i,sum=0;t=load_equ();system("cls");printf("Please input th
43、e start time:_._._bbbbbbbbbbb");scanf("%s",year1);printf("n");printf("Please input the finish time:_._._bbbbbbbbbbb");scanf("%s",year2);printf("n"); for(i=0;i<t;i+) if(strcmp(equi.b_time,year1)>=0)&&(strcmp(equi.b_time,year2)<=0
44、) sum+; save_statistic_record(i);/*把符合條件的記錄保存在查詢記事本里*/ if(sum=0) system("cls");printf("*nn");printf(" Sorry! Cannot find the equipment which you want to!nn");printf("*nn");getch(); else system("cls");printf("*nn");printf(" There are%-2
45、dequipment(s) which you want to statistic in the record!nn",sum);printf("*nnnn");getch(); printf("Press any key to go back the former step.n"); getchar(); menu();void tb_gb_tq()char year111,year211;int t,i,sum=0;t=load_equ();system("cls");printf("Please input
46、the start time:_._._bbbbbbbbbbb");scanf("%s",year1);printf("n");printf("Please input the finish time:_._._bbbbbbbbbbb");scanf("%s",year2);printf("n"); for(i=0;i<t;i+) if(strcmp(equi.giveb_time,year1)>=0)&&(strcmp(equi.giveb_time,ye
47、ar2)<=0) sum+; save_statistic_record(i);/*把符合條件的記錄保存在查詢記事本里*/ if(sum=0) system("cls"); printf("*nn"); printf(" Sorry! Cannot find the equipment which you want to!nn"); printf("*nn"); getch(); else system("cls"); printf("*nn"); printf(&qu
48、ot; There are%-2dequipment(s) which you want to statistic in the record!nn",sum); printf("*nnnn"); getch(); printf("Press any key to go back the former step.n"); getchar(); menu(); (7)顯示記錄模塊 /*顯示記錄模塊*/void load_record()int t;t=load_equ();printf_n(t);system("cls");p
49、rintf("nnnPress any key to go back.nn");getch();getchar();menu(); 公共函數下面是在每個功能模塊中都有可能用到的一些公共函數。(1) 保存函數save(int n)(2) void save(int n,int m)/*n表示保存n組數據,m表示保存在哪個文件夾里*/(3) (4) FILE *fp;(5) int i;(6) if(m=0)(7) fp=fopen("record.txt","w");/*以只寫方式打開*/(8) else if(m=1)(9) fp=fopen("search_record.txt","w");(10) else(11)
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 工業節能技術與解決方案
- 工業設計的新趨勢與挑戰
- 工業設計的發展趨勢與創新
- 工作習慣優化從小事做起
- 工作場所中的危機公關處理
- 工程塑料在注塑制品中的應用與發展研究
- 工程師培訓中的數據采集與處理方法
- 工程勘察與數據處理的一體化趨勢
- 工程地質勘察中的無人機技術應用
- 工程結構分析與機械設計的融合
- 大學語文-第四講魏晉風度和魏晉文學-課件
- 我們畢業啦畢業季通用模板課件
- 小升初數學復習八(平面圖形)講義課件
- (完整版)基建建設工程流程圖
- 墻體開槽技術交底及記錄
- 國家開放大學《調劑學(本)》形考任務1-4參考答案
- 公務員工資套改和運行案例
- 鐵路貨物裝載常用計算公式
- 哥尼斯堡七橋問題PPT課件
- 總包(消防)管理方案
- 工具鉗工理論知識鑒定要素細目表09版
評論
0/150
提交評論