1、 前 言计算机科学技术的发展,不仅极大地促进了整个科学技术的发展,而且明显地加快了经济信息化和社会信息化的进程。因此,计算机教育在全国备受重视,计算机知识与能力已成为21世纪人才素质的基本要素之一。信息时代的发展,影响着世界的每一个角落。每个人的生活和工作几乎都与计算机密切相关。在速度越来越快的计算机硬件和日益更新的软件背后,网络作为中枢神经把我们联系在一起。也正是因为网络的出现与发展,使Internet为主要标志的网络技术构成了我们现代文化的重要组成部分,联系上亿人的Internet将我们带入了一个新的网络时代。机遇就在眼前,挑战同样存在。优胜劣汰是不可抗拒的自然法则,欲保持领先的地位,持之
2、以恒的学习是惟一途径。计算机技术发展如此迅猛,计算机应用如此广泛,需要学习的东西愈来愈多,而我们的总学时是有限的。一般来说,计算机课程学习可以分为两部分:一部分是理论课程学习,一部分是上机应用实习。根据我们专业的性质和要求,则应侧重于上机操作运用。为此,学校特意在寒假最后一星期安排了32个学时的上机实习。现将一星期的实习内容及结果分析分列如下:仪器仪表管理一 题目要求1 新的仪器仪表信息的录入。2 在借出,归还,维修时对仪器仪表的信息的修改。3 对报废仪器仪表信息的删除。4 按照一定的条件查询统计符合条件的仪器仪表信息;查询功能至少应该包括仪器仪表基本信息的查询按时间段 (如在2004年1月1
3、日到2004年10月10日购买,借出,维修的仪器仪表等)查询按时间点(借入时间,借出时间,归还时间)查询等,统计功能至少包括按时间段统计按仪器仪表的基本信息统计等。5 对查询统计的结果打印输出。二 需求分析根据题目要求,数据以文件的形式存储,所以应提供文件的输入,输出等操作;还需要文件具有查找,替换,修改数据的功能三 总体设计根据上面的需求分析,可以将这个系统的设计分为如下七大模块:输入,显示,修改,删除,查询,统计,退出。仪 器 仪 表 管 理 仪器仪表管理输入显示修改 查询统计退出删除四 详细设计1 主函数为了各模块的独立性,主函数一般设计得比较简单,本系统主要用主函数打开上次保存的数据和
4、进入主菜单函数流程图打开上次保存文件进入主菜单函数程序/*主函数*/main() (main函数)menu(); (主菜单函数)主菜单流程图显示一系列功能选项输入n,n1或n7根据n的值调用各功能模块函数否是void menu()int w,n;doprintf(tt WELCOME TO THE EQUIPMENT MANAGEMENT SYSTEMnnn);printf(nntt=*=nnn);printf(ttt1:Add message of new equipmentnn);printf(ttt2:Load the message of all equipmentnn);printf
5、(ttt3:Correct the message of equipmentnn);printf(ttt4:Delete the message of broken equipmentnn);printf(ttt5:Search the message of equipmentnn);printf(ttt6:Search of all the equipmentnn);printf(ttt7:Exitn);printf(nntt=*=nnn);printf(Please choice your number: bb);scanf(%d,&n);if(n7) w=1;else w=0;while
6、 (w=1);(dowhile.对不是1到7的数字进行屏蔽)/*选择功能*/switch(n) (switch函数进行菜单选择)case 1:add_new_message();break;/*输入模块*/case 2:load_record();break;/*显示模块*/case 3:modify();break;/*修改模块*/case 4:delete();break;/*删除模块*/case 5:search();break;/*查询模块*/case 6:statistic();break;/*统计模块*/case 7:exit();break;/*退出模块*/这是本程序的菜单功能,
7、主要包括输入,显示,修改,删除,查询,统计,退出7个功能,下面是各个功能模块的具体程序部分。2 各功能模块设计一添加模块程序/*添加*/void add_new_message()int t,i,m;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;im;i+)printf(nInput %dth equipment record.n,i+1);input(t+i);/*调用输入函数*/ (对新的数据的输入)save
8、(t+m,0);/*调用保存函数 保存t+m组数据*/ menu();/*返回登陆界面*/*输入函数*/ 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.name,&equi.b_time,&equi.bin_time,&equi.bout_time,&equi.giveb_time,&equi.repair_time,&equi.state
9、);b time 购买时间 b in time 借进时间 b out time 借出时间 g back time 归还时间 repair time 维修时间 state 状态二加载程序 程序/*加载*/*显示记录模块*/void load_record()int t;t=load_equ();printf_n(t);printf(nnnPress any key to go back.nn);getch();menu();/*显示一个仪器记录的函数*/void printf_one(int i)printf(%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d
10、.nn,equi.number,equi.name,equi.b_time,equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);/*显示n个仪器记录的函数*/void printf_n(int n)int j;printf(number name b_time b_in_time b_out_time g_back_time repair_time sn);for(j=0;jn;j+) if(j+1)%10=0)/*控制显示,每屏显示10行*/ printf(nnPass any key to co
11、ntinue .); getch(); puts(nn); printf_one(j);/*调用显示一个仪器记录的函数*/ 三修改模块程序/*修改*/void modify()struct equip mod;int t,i,m,w,addr=-1;char number4= , name11= ;t=load_equ();doprintf(nInput the equipmentnumber or name ( 1:the number 2:the name ):nn);printf(What is your choice: bb);scanf(%d,&m);if(m=1|m=2) w=0;
12、else w=1;while(w=1);switch(m) case 1: printf(nnPlease input the equipments number:_bbbb); scanf(%s,number);break; case 2: printf(Please input the equipments name:_bbbbbbbbbbb); scanf(%s,name);break;for(i=0;it;i+)/*查找要修改的仪器*/ if(strcmp(equi.name,name)=0|strcmp(equi.number,number)=0) addr=i; printf(nn
13、Please 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.number,mod.name,mod.b_time, mod.bin_time,mod.bout_time,mod.giveb_time,mod.repair_time,&mod.state); strcpy(equi.number,mod.number); strcpy(equi.name,mod.name);
14、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_time); strcpy(equi.repair_time,mod.repair_time); equi.state=mod.state; printf(%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn,equi.number,equi.name,equi.b_time, e
15、qui.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);break; if(addr=-1) printf( Cannot find the equipment which you want to modify!nn); printf( Press any key to go back.nn); getch(); menu(); save(t,0);/*修改后的信息保存*/printf( Press any key to go back.nn);getch();menu();四删除模块程序/*删除*/vo
16、id delete()FILE *fp1;struct equip mod;int t,i,m,w,addr=-1,u;char number4= , name11= ;char a12,a22;t=load_equ();if(fp1=fopen(c:record.txt,w)=NULL)/*以只写方式打开*/ printf(nCannot open filen); exit(0); do printf(nPlease Input the equipmentnumber or name to find it( 1:the number 2:the name ):nn); printf(What
17、 is your choice: 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 equipments number:(_)bbbb); scanf(%s,number);break; case 2: printf(Please input the equipments name:(_)bbbbbbbbbbb); scanf(%s,name);break;for(i=0;it;i+)/*查找要删除的仪器*/ if(strcmp(equi.na
18、me,name)=0|strcmp(equi.number,number)=0) addr=i; printf(%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.nn,equi.number,equi.name,equi.b_time, equi.bin_time,equi.bout_time,equi.giveb_time,equi.repair_time,equi.state);rintf(Congratunations ! You have been successful to delete its information. _n); continu
19、e; fwrite(&equi,sizeof(struct equip),1,fp1);/*把不想删除的保存在记事本里,想删除的不保存即为删除*/ fclose(fp1);/*关闭文件*/if(addr=-1) printf( Cannot find the equipment which you want to delete!nn); printf( nnnPress any key to go back.nn); getch(); menu();五查询模块程序/*查询*/void search()int w,n;doprintf(ntt*nn);printf(ttby b_time qua
20、ntum 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( Choice your number(1-4): bbb);scanf(%d,&n);if(n4) w=1;else w=0;while (w=1);/*选择功能*/switch(n)case 1:sb_buy_tq();break;/*按购买
21、时间段查询函数*/case 2:sb_gb_tq();break;/*按归还时间段查询*/case 3:sb_par_number();break;/*按指定编号查询*/case 4:sb_name();break;/*按仪器名称查询*/void sb_buy_tq()/*按购买时间段查询函数*/char year111,year211;int t,i,sum=0;t=load_equ();printf(Please input the start time:_._._bbbbbbbbbb);scanf(%s,year1);printf(n);printf(Please input the f
22、inish time:_._._bbbbbbbbbb);scanf(%s,year2);printf(n); for(i=0;i=0)&(strcmp(equi.b_time,year2)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save(1,1);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) printf(Sorry! Cannot find the equipment which you want to.nn); printf(Press any key to go back the former step.n); getch();
23、 menu();void sb_gb_tq()/*按购买时间段查询函数*/char year111,year211;int t,i,sum=0;t=load_equ();printf(Please input the start time:_._._bbbbbbbbbb);scanf(%s,year1);printf(n);printf(Please input the finish time:_._._bbbbbbbbbb);scanf(%s,year2);printf(n); for(i=0;i=0)&(strcmp(equi.b_time,year2)=0) printf_one(i);
24、/*把符合条件的记录显示出来*/ sum+; save(1,1);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) printf(*nn); printf(Sorry! Cannot find the equipment which you want to.nn); printf(*nn); printf(Press any key to go back the former step.n); getch(); menu();void sb_par_number()/*按指定编号查询*/char number4;int t,i,sum=0;t=load_equ();printf(
25、Please input the equipment number(000999):_bbbb);scanf(%s,number);printf(n); for(i=0;it;i+) if(strcmp(equi.number,number)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save(1,1);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) printf(Sorry! Cannot find the equipment which you want to.nn); printf(Press any key to go back t
26、he former step.n); getch(); menu();void sb_name()/*按仪器名称查询*/char name11;int t,i,sum=0;t=load_equ();printf(Please input the equipment name:_bbbbbbbbbbb);scanf(%s,name);printf(n); for(i=0;it;i+) if(strcmp(equi.name,name)=0) printf_one(i);/*把符合条件的记录显示出来*/ sum+; save(1,1);/*把符合条件的记录保存在查询记事本里*/ if(sum=0)
27、 printf(Sorry! Cannot find the equipment which you want to.nn); printf(Press any key to go back the former step.n); getch(); menu();六统计模块程序/*统计模块*/void statistic()int w,n;doprintf(ntt*nn);printf(ttby b_time quantum to statistic? Input1n);printf(ttby give_back_time quantum to statistic? Input2n);prin
28、tf(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(n4) w=1;else w=0;while (w=1);/*选择功能*/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
29、_par_number()char number4;int t,i,sum=0;t=load_equ();printf(Please input the equipment number(000999):_bbbb);scanf(%s,number);printf(n); for(i=0;it;i+) if(strcmp(equi.number,number)=0)(如果号码对应就进行计数) sum+; save(1,2); if(sum=0) printf( Sorry! Cannot find the equipment which you want to!nn); else printf
30、( There are%-2dequipment(s) which you want to statistic in the record!nn,sum); printf(Press any key to go back the former step.n); getch(); menu();void tb_name()char name11;int t,i,sum=0;t=load_equ();printf(Please input the equipment name:_bbbbbbbbbbb);scanf(%s,name);printf(n); for(i=0;it;i+) if(str
31、cmp(equi.name,name)=0) sum+; save(1,2);/*把符合条件的记录保存在查询记事本里*/ if(sum=0) printf( Sorry! Cannot find the equipment which you want to!nn); else printf( There are%-2dequipment(s) which you want to statistic in the record!nn,sum); printf(Press any key to go back the former step.n); getch(); menu();void tb
32、_buy_tq()char year111,year211;int t,i,sum=0;t=load_equ();printf(Please input 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=0)&(strcmp(equi.b_time,year2)=0) sum+; save(1,2);/*把符合条件的记录保存在查询记事本里*/ if
33、(sum=0) printf(*nn); printf( Sorry! Cannot find the equipment which you want to!nn); printf(*nn); else printf(*nn); printf( There are%-2dequipment(s) which you want to statistic in the record!nn,sum); printf(*nnnn); printf(Press any key to go back the former step.n); getch(); menu();void tb_gb_tq()char year111,year211;int t,i,sum=0;t=load_equ();printf(Please input the start time:_._._bbbbbbbbbbb);scanf(%s,year1);printf(n);printf(Please input the finish time:_._._bbbbbbbbbbb);scanf(%s,year2);printf(n); for(i=0;it;i+) if(s