仪器仪表管理系统—C语言课程设计
仪器仪表管理
1.题目要求
Ⅰ.【要求】
系统功能的基本要求:
(1)新的仪器仪表信息的录入;
(2)在借出、归还、维修时对仪器仪表信息的修改;
(3)对报废仪器仪表信息的删除;
(4)按照一定的条件查询符合条件的仪器仪表信息;查询功能至少应该包括仪器仪表基本信息(如仪器仪表名字、仪器仪表编等)的查询、按时间点(借入时间、借出时间、归还时间)查询等
(5)对查询结果的输出。
【提示】
数据结构采用结构体。仪器仪表信息包括仪器仪表名、仪器仪表编号、购买时间、借入时间、借出时间、归还时间、维修时间、状态信息(0代表可借出,1代表已借出,2代表正在维修)等。
Ⅱ.需求分析
根据题目要求,需要把仪器仪表信息的的数据存储在文件里,所以需要提供文件的输入输出等操作;在程序中要提供修改,删除,查找等操作;另外还应该提供键盘式选择菜单实现功能选择。
2.功能实现设计
2.1总体设计
系统功能模块图
2.2详细设计
1.主函数
主函数一般设计得比较简洁,只提供输入输出和功能处理的函数调用。
其各功能模块用菜单方式选择。本题将main()函数体内的界面选择部分语句单独抽取出来作为一独立函数,目的在于系统执行完每部分功能模块后能够方便返回到系统界面。
【程序】
main()
{menu();
}
菜单部分设计如下:
【流程图】
【程序】
main()
{
menu();
}
void menu()
{
int w,n;
do
{
system("cls");
printf("\t\t WELCOME TO THE EQUIPMENT MANAGEMENT
SYSTEM\n\n\n");
printf("\n\n\t\t====================******=================== =\n\n\n");
printf("\t\t\t1:Add message of new equipmen\n\n");
printf("\t\t\t2:Load the message of all equipment\n\n");
printf("\t\t\t3:Correct the message of equipment\n\n");
printf("\t\t\t4:Ddlete the message of broken equipment\n\n");
printf("\t\t\t5:Search the message of equipment\n\n");
printf("\t\t\t6:Search of all the equipment\n\n");
printf("\t\t\t7:Exit\n");
printf("\n\n\t\t====================******================== ==\n\n\n");
printf("Please choice your number:[ ]\b\b");
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:search();break;/*查询模块*/
case 6:statistic();break;/*统计模块*/
case 7:exit(0);break;/*退出模块*/
}
}
2.各功能模块设计
(1)添加模块
【数据结构】
【分析】
单独看各数据信息,仪器仪表名是字符型,可采用字符型数组;仪器仪表编
号、购买时间、借入时间、借出时间、归还时间、维修时间应采用实型;状
态信息是整数,采用整型。实际上操作时发现只有字符型的数据可以在文件
中成功被保存,所以本题所有数据一律采用字符型。
struct equip
{
char number[4];
char name[11];
char b_time[11];
char bin_time[11];
char bout_time[11];
char giveb_time[11];
char repair_time[11]; /*time为下面程序中按时间查找和修改时记录输入的时间*/
int state;
}equ[M];
【注意】
equ[M]中的M是仪表仪器个数,程序中采用宏定义的方式,可以随时在源
程序宏定义中改,本程序宏定义#define M 50。
【流程图】
输入模块流程图
【程序】/****************添加模块****************/
void add_new_message()
{
int t,i,m;
system("cls");
t=load_equ();
printf("How many groups datas do you want to add?\n");
printf("input the number:[ ]\b\b\b");
scanf("%d",&m);
for(i=0;i { printf("\nInput %dth equipment record.\n",i+1); input(t+i);/*调用输入函数*/ } save(t+m,0);/*调用保存函数保存t+m组数据*/ system("cls"); menu();/*返回登陆界面*/ } /****************输入函数****************/ void input(int i) { printf("Please input:\nnumber name b_time b_in_time b_out_time g_back_time repair_time state\n"); scanf("%s %s %s %s %s %s %s %d",&equ[i].number,&equ[i].name,&equ[i].b_time,&equ[i].bin _time,&equ[i].bout_time,&equ[i].giveb_time,&equ[i].repair_time,&equ[i].state); } /*显示记录模块*/ void load_record() { int t; t=load_equ(); printf_n(t); printf("\n\n\nPress any key to go back...\n\n"); getchar(); menu(); } /*显示一个仪器记录的函数*/ void printf_one(int i) { printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.\n\n",equ[i].number,equ[i].name,equ[i].b_time,equ[i].bin_time,equ[i].bout_time,equ[i].g iveb_time,equ[i].repair_time,equ[i].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 s\n"); for(j=0;j { if((j+1)%10==0)/*控制显示,每屏显示10行*/ { printf("\n\nPass any key to continue ..."); getchar(); puts("\n\n"); } printf_one(j);/*调用显示一个仪器记录的函数*/ } } (2)修改模块 [需求分析] 该模块的功能是显示所有仪器仪表信息,考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户修改该记录的哪部分信息,是仪器仪表的借出时间、归还时间、修理时间还是状态,根据用户选择修改相应信息。 [流程图] [程序] /*************************修改模块***********************/ void modify() { struct equip mod; int t,i,m,w,addr=-1; char number[4]={' '}, name[11]={' '}; system("cls");/*清屏*/ t=load_equ(); do { printf("\nInput the equipment'number or name ( 1:the number 2:the name ):\n\n"); printf("What is your choice:[ ]\b\b"); scanf("%d",&m); if(m==1||m==2) w=0; else w=1; } while(w==1); switch(m) { case 1: printf("\n\nPlease input the equipment's number:[___]\b\b\b\b"); scanf("%s",number);break; case 2: printf("Please input the equipment's name:[__________]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",name);break; } for(i=0;i { if(strcmp(equ[i].name,name)==0||strcmp(equ[i].number,number)==0) { addr=i; printf("\n\nPlease input the new information:\n\n"); printf("number name b_time b_in_time b_out_time g_back_time repair_time s\n"); scanf("%s%s%s%s%s%s%s%d",mod.number,https://www.360docs.net/doc/fd19137832.html,,mod.b_time, mod.bin_time,mod.bout_time,mod.giveb_time,mod.repair_time,&mod.state); strcpy(equ[i].number,mod.number);strcpy(equ[i].name,https://www.360docs.net/doc/fd19137832.html,);strcpy(equ[i].b_time,mod. b_time); strcpy(equ[i].bin_time,mod.bin_time);strcpy(equ[i].bout_time,mod.bout_time); strcpy(equ[i].giveb_time,mod.giveb_time); strcpy(equ[i].repair_time,mod.repair_time); equ[i].state=mod.state; printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.\n\n",equ[i].number,equ[i].name,equ[i].b_time,equ[i].bin_time,equ[i].bout_time,equ[i].gi veb_time,equ[i].repair_time,equ[i].state);break; } } if(addr==-1) { printf(" Cannot find the equipment which you want to modify!\n\n"); printf(" Press any key to go back...\n\n"); getchar(); menu(); } save(t,0);/*修改后的信息保存*/ printf(" Press any key to go back...\n\n"); getchar(); menu(); } (3)查询模块 [流程图] 查询模块流程图 [程序] /****************查询模块****************/ void search() { int w,n; do { system("cls"); printf("\n\t\t*********************************************\n\n"); printf("\t\tby b_time quantum to search? Input[1]\n"); printf("\t\tby give_back_time quantum to search? Input[2]\n"); printf("\t\tby number to search? Input[3]\n"); printf("\t\tby name to search? Input[4]\n"); printf("\t\t*********************************************\n\n"); printf(" Choice your number(1-4):[ ]\b\b\b"); 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()/*按购买时间段查询函数*/ { char year1[11],year2[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the start time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year1); printf("\n"); printf("Please input the finish time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year2); printf("\n"); system("cls"); for(i=0;i { if((strcmp(equ[i].b_time,year1)>=0)&&(strcmp(equ[i].b_time,year2)<=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.\n\n"); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void sb_gb_tq()/*按购买时间段查询函数*/ { char year1[11],year2[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the start time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year1); printf("\n"); printf("Please input the finish time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year2); printf("\n"); system("cls"); for(i=0;i { if((strcmp(equ[i].giveb_time,year1)>=0)&&(strcmp(equ[i].b_time,year2)<=0)) { printf_one(i);/*把符合条件的记录显示出来*/ sum++; save_search_record(i);/*把符合条件的记录保存在查询记事本里*/ } } getch(); if(sum==0) { system("cls"); printf("***************************************************\n\n"); printf("Sorry! Cannot find the equipment which you want to.\n\n"); printf("***************************************************\n\n"); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void sb_par_number()/*按指定编号查询*/ { char number[4]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the equipment number(000~999):[___]\b\b\b\b"); scanf("%s",number); printf("\n"); system("cls"); for(i=0;i { if(strcmp(equ[i].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.\n\n"); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void sb_name()/*按仪器名称查询*/ { char name[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the equipment name:[__________]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",name); printf("\n"); system("cls"); for(i=0;i { if(strcmp(equ[i].name,name)==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.\n\n"); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } (4)删除模块 [需求分析] 该模块的功能与修改模块一样先显示所有仪器仪表信息,同样考虑到记录较多,建议采用分屏显示。显示完所有记录后,用户输入要修改的仪器仪表编号,根据编号查找仪器仪表记录,并提示用户是否确定要删除。 [流程图] 删除模块流程图 [程序] /*************************删除模块***********************/ 3.void delete1() 4.{ 5.FILE *fp1; 6.//struct equip mod; 7.int t,i,m,w,addr=-1; 8.char number[4]={' '}, name[11]={' '}; 9. //char a1[2],a2[2]; 10.system("cls");/*清屏*/ 11.t=load_equ(); 12.if((fp1=fopen("record.txt","w"))==NULL)/*以只写方式打开*/ 13. { 14.printf("\nCannot open file\n"); 15.exit(0); 16. } 17.system("cls"); 18.do 19. { 20.system("cls"); 21.printf("\nPlease Input the equipment'number or name to find it( 1:the number 2:the name ):\n\n"); 22.printf("What is your choice:[ ]\b\b"); 23.scanf("%d",&m); 24.if(m==1||m==2) 25.w=0; 26.else 27.w=1; 28. }while(w==1); 29. 30.switch(m) 31.{ 32.case 1: 33.printf("\n\nPlease input the equipment's number:(___)\b\b\b\b"); 34.scanf("%s",number);break; 35.case 2: 36.printf("Please input the equipment's name:(__________)\b\b\b\b\b\b\b\b\b\b\b"); 37.scanf("%s",name);break; 38.} 39. 40.for(i=0;i 41.{ 42.if(strcmp(equ[i].name,name)==0||strcmp(equ[i].number,number)==0) 43.{ 44. addr=i; 45. system("cls"); 46.printf("%-3s %-10s %-10s %-10s %-10s %-10s %- 10s %d.\n\n",equ[i].number,equ[i].name,equ[i].b_time,equ[i].bin_time,equ[i].bout_time,equ[i ].giveb_time,equ[i].repair_time,equ[i].state); getch(); system("cls"); printf("Congratunations ! You have been successful to delete it's information. ^_^\n"); getch(); continue; } fwrite(&equ[i],sizeof(struct equip),1,fp1);/*把不想删除的保存在记事本里,想删除的不保存即为删除*/ } fclose(fp1);/*关闭文件*/ if(addr==-1) { system("cls"); printf(" Cannot find the equipment which you want to delete!\n\n"); getch(); } printf(" \n\n\nPress any key to go back...\n\n"); getchar(); menu(); } (6)统计模块 按要求可按时间段统计按基本信息统计并保存至统计记录文档流程图类似查询模块 /****************统计模块****************/ void statistic() { int w,n; do { system("cls"); printf("\n\t\t*********************************************\n\n"); printf("\t\tby b_time quantum to statistic? Input[1]\n"); printf("\t\tby give_back_time quantum to statistic? Input[2]\n"); printf("\t\tby number to statistic? Input[3]\n"); printf("\t\tby name to statistic? Input[4]\n"); printf("\t\t*********************************************\n\n"); printf(" Choice your number(1-4):[ ]\b\b\b"); scanf("%d",&n); if(n<1||n>4) 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_par_number() { char number[4]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the equipment number(000~999):[___]\b\b\b\b"); scanf("%s",number); printf("\n"); for(i=0;i { if(strcmp(equ[i].number,number)==0) { sum++; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ } } if(sum==0) { system("cls"); printf(" Sorry! Cannot find the equipment which you want to!\n\n"); getch(); } else { system("cls"); printf(" There are[%-2d]equipment(s) which you want to statistic in the record!\n\n",sum); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void tb_name() { char name[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the equipment name:[__________]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",name); printf("\n"); for(i=0;i { if(strcmp(equ[i].name,name)==0) { sum++; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ } } if(sum==0) { system("cls"); printf(" Sorry! Cannot find the equipment which you want to!\n\n"); getch(); } else { system("cls"); printf(" There are[%-2d]equipment(s) which you want to statistic in the record!\n\n",sum); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void tb_buy_tq() { char year1[11],year2[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the start time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year1); printf("\n"); printf("Please input the finish time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year2); printf("\n"); for(i=0;i { if((strcmp(equ[i].b_time,year1)>=0)&&(strcmp(equ[i].b_time,year2)<=0)) { sum++; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ } } if(sum==0) { system("cls"); printf("**************************************************************\n\n" ); printf(" Sorry! Cannot find the equipment which you want to!\n\n"); printf("**************************************************************\n\n" ); getch(); } else { system("cls"); printf("****************************************************************** *******\n\n"); printf(" There are[%-2d]equipment(s) which you want to statistic in the record!\n\n",sum); printf("****************************************************************** *******\n\n\n\n"); getch(); } printf("Press any key to go back the former step...\n"); getchar(); menu(); } void tb_gb_tq() { char year1[11],year2[11]; int t,i,sum=0; t=load_equ(); system("cls"); printf("Please input the start time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year1); printf("\n"); printf("Please input the finish time:[____.__.__]\b\b\b\b\b\b\b\b\b\b\b"); scanf("%s",year2); printf("\n"); for(i=0;i { if((strcmp(equ[i].giveb_time,year1)>=0)&&(strcmp(equ[i].giveb_time,year2)<=0)) { sum++; save_statistic_record(i);/*把符合条件的记录保存在查询记事本里*/ } } if(sum==0) { system("cls"); printf("**************************************************************\n\n"); printf(" Sorry! Cannot find the equipment which you want to!\n\n"); printf("**************************************************************\n\n"); getch(); } else { system("cls"); printf("************************************************************************* \n\n"); printf(" There are[%-2d]equipment(s) which you want to statistic in the record!\n\n",sum); printf("************************************************************************* \n\n\n\n"); 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"); printf("\n\n\nPress any key to go back...\n\n"); 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) fp=fopen("statistic_record.txt","w"); (12)if(fp==NULL) (13){ (14)printf("\nCannot open file\n"); (15)exit(0); (16)} (17)for(i=0;i (18){ (19) fwrite(&equ[i],sizeof(struct equip),1,fp); (20)} (21) fclose(fp); (22)Search保存函数 (23)void save_search_record(int i) (24){ (25)FILE *fp; (26)fp=fopen("search_record.txt","a"); (27)fwrite(&equ[i],sizeof(struct equip),1,fp); (28) fclose(fp); (29)} (30)Statistic保存函数 (31)void save_statistic_record(int i) (32){ (33)FILE *fp; (34)fp=fopen("statistic_record.txt","a"); (35)fwrite(&equ[i],sizeof(struct equip),1,fp); (36) fclose(fp); (37)} (38)输入整一个记录函数input(int i) [说明] 形参i表示第i个仪器仪表的记录。 [程序] void input(int i) { printf("Please input:\nnumber name b_time b_in_time b_out_time g_back_time repair_time state\n"); scanf("%s %s %s %s %s %s %s %d",&equ[i].number,&equ[i].name,&equ[i].b_time,&e qu[i].bin_time,&equ[i].bout_time,&equ[i].giveb_time,&equ[i].repair_time,&equ[i].state ); } (39)加载函数load() [说明] 该函数可以用来加载所有记录,并且可以返回所有记录的个数。 [程序] (40)int load_equ()/***加载仪器信息并计算记录仪器个数的函数***/ (41){ (42)FILE *fp; (43)int i; (44)if((fp=fopen("record.txt","rb"))==NULL)/*以只读方式打开*/ (45) { (46)printf("\nCannot open file\n"); (47)exit(0); (48) } (49)for(i=0;!feof(fp);i++)/*从文件中读入数据并保存在结构体数组中*/ (50)fread(&equ[i],sizeof(struct equip),1,fp); (51)fclose(fp); (52)return(i-1); (53)} (54)显示n个记录的函数 (55)void printf_n(int n) (56){ (57)int j; (58)system("cls");/*清屏*/ (59)printf("number name b_time b_in_time b_out_time g_back_time repair_time s\n"); (60)for(j=0;j (61) { (62) if((j+1)%10==0)/*控制显示,每屏显示10行*/ (63) { (64) printf("\n\nPass any key to continue ..."); (65) getchar(); (66) puts("\n\n"); (67) } (68)printf_one(j);/*调用显示一个仪器记录的函数*/ (69) } (70)} (71)显示一个记录的函数 (72)void printf_one(int i) (73){ (74)printf("%-3s %-10s %-10s %-10s %-10s %-10s %-10s %d.\n\n",equ[i].number,equ[i].name,equ[i].b_time,equ[i].bin_time,equ[i].bout_time, equ[i].giveb_time,equ[i].repair_time,equ[i].state); (75)} 二、上机操作 1.数据源: 为了保存数据,需要建立一个record.txt文件 2.编译、连接和运行 3.结果 下面是各个模块的界面图: (1)主菜单函数 1 设计目的 机房机位预定系统 2 任务概述 20台机器,编号1到20,从早八点到晚八点。两小时一个时间段,每次可预定一个时间段。功能要求: (1)系统以菜单方式工作 (2)查询,根据输入时间,输出机位信息。 (3)机位预定,根据输入的时间查询是否有空机位,若有则预约,若无则提供最近的时间段,另:若用户在非空时间上机,则将用户信息列入等待列表。 (4)退出预定,根据输入的时间,机器号撤销该事件的预定! (5)查询是否有等待信息,若有则提供最优解决方案(等待时间尽量短),若无则显示提示信息。 ......... 3 模块划分 4 主要函数说明及其N-S图 1.主函数: int main() { Menu(); /*当前状态函数*/ } void Menu() /*主界面*/ { int n,w; do { puts("\t\t****************机房机位预约系统*******************\n"); puts("\t\t*************************菜单 ***************************\n"); puts("\t\t\t 1.查询某时间段机位状态"); /*查询某时间段机位状态*/ puts("\t\t\t 2.预定空机位"); /*预定空机位*/ puts("\t\t\t 3.取消预订"); /*取消预订*/ puts("\t\t\t 4.查询等待信息"); /*查询等待信息*/ puts("\t\t\t 5.退出"); /*退出*/ puts("\t\t********************************************************\n"); printf("选择菜单号(1-5):"); scanf("%d",&n); if(n<1||n>5) {w=1;getchar();} else w=0; }while(w==1); switch(n) { case 1:Situation();break; case 2:Book();break; case 3:Cancel();break; case 4:SearchWaiting();break; case 5:exit(0);break; } getch(); } 2.机位查询: void Situation() { int time; printf("输在 (8-20)范围内的时间:"); scanf("%d",&time); if(time<8||time>20) {printf("\t时间输入错误!\n"); printf("输入在 (8-20)范围内的时间:"); scanf("%d",&time); } detail(time); /*函数调用*/ getchar(); Menu();} 3.机位预定: C 语言课程设计(小游戏贪吃蛇的程序设计报告) 设计人: 班级: 201 年月号 目录一:概述 1:研究背景及意义 2:设计的任务与需要知识点3:具体完成设计内容 二:需求分析 1:功能需求 2:操作方法 三:总体设计 1:模块划分 2:数据结构设计 四:详细设计 1:主空摸块设计 2:绘制游戏界面 3:游戏的具体过程 4:游戏的结束处理 5:显示排行榜信息模块 五:程序的调试与测试1:动画与音乐同步 2:蛇的运行 3:终止程序 六:结论 七::结束语 八:程序清单 九:参考文献 一. 概述 本课程设计以软件工程方法为指导,采用了结构化,模块化的程序设计方法,以C语言技术为基础,使用Turbo C++3、0为主要开发工具,对贪吃蛇游戏进行了需求分析,总体设计,详细设计,最终完成系统的实现与测试。 1、1 研究的背景及意义 随着社会的发展,人们生活的节奏日益加快,越来越多的人加入了全球化的世界。人们不再拘泥与一小块天地,加班,出差成了现代人不可避免的公务。而此时一款可以随时随地娱乐的游戏成为了人们的需要。此次课程设计完成的贪吃蛇小游戏,正就是为了满足上述需求而设计出来的。贪吃蛇游戏虽小,却设计诸多的知识点。通过开发贪吃蛇游戏系统,可使读者初步了解使用软件工程的与那个发,技术与工具开发软件的过程,进一步掌握结构化,模块化的程序设计方法与步骤,进一步掌握总体数据结构设计,模块划分方法,掌握局部变量,全局变量,结构体,共用体,数组,指针,文件等数据结构的使用方法,掌握图形,声音,随机数等多种库函数的使用方法,学习动画,音乐,窗口,菜单,键盘等多项编程技术,进一步学会软件调试,测试,组装等软件测试方法,为后续课程的学习与将来实际软件开发打下坚实的基础。 1、2 设计的任务与需要的知识点 1、2、1 课程设计主要完成的任务 1)、通过编写“贪吃蛇游戏”程序,掌握结构化,模块块化程序设计的思想,培养解决实际问题的能力。 2) 有同步播放动画,声音效果。 3) 设计好数组元素与蛇,食物的对应关系。 4) 随机产生食物。 5) 有分数统计,排行榜,分数存储等功能。 通过此次课程设计,希望使读者能更深入的理解与掌握课程教学中的基本概念,培养读者应用基本技术解决实际问题的能力,从而进一步提高分析问题与解决问题的能力。 1、2、2需要掌握与运用的知识点 1、2、3本次课程设计需要掌握与运用如下的知识点: 1) 数组的应用。 2) 全局变量的使用。 3) 按键处理。 4)结构体的应用。 5)图形,音乐与动画的有关知识。 6)随即函数的使用。 7)文件的基本出操作。 8) 结构化,模块化的设计方法。 1、新建“.h”头文件,将“头文件” 代码粘贴至其中, 2、新建“.c”源文件,将“源代码” 代码粘贴到其中。 3、新建空白工程,将头文件和源代码 添加进去,调试使用。 //头文件 //1.自定义枚举类型,定义7种形态的游戏方块 typedef enum tetris_shape { ZShape=0, SShape, LineShape, TShape, SquareShape, LShape, MirroredLShape }shape; //2.函数声明 //(1)操作方块函数 int maxX();//取得当前方块的最大x坐标 int minX();//取得当前方块的最小x坐标 void turn_left();//当前方块逆时针旋转90度 void turn_right(); int out_of_table(); void transform(); int leftable(); int rightable(); int downable(); void move_left(); void move_right(); //(2)操作游戏桌面的函数 int add_to_table(); void remove_full(); //(3)控制游戏函数 void new_game(); void run_game(); void next_shape(); int random(int seed); //(4)绘图函数 void paint(); void draw_table(); //(5)其他功能函数 void key_down(WPARAM wParam); void resize(); void initialize(); void finalize(); //(6)回调函数,用来处理Windows消息 LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM); //源代码 //1.文件包含 #include 实验报告 一、问题陈述及其需求分析 (一)问题陈述 学生信息管理系统是对学生信息的基本管理,其中包括以下及模块: (1)增加一个学生的信息(需输入要增加学生的所有信息); (2)统计本班学生总人数及男女生人数。 (3)分别按照学号查找学生的信息;若找到则输出该学生全部信息,否则输出查找不到的提示信息。 (4)按学号对所有学生信息排序,并输出结果; (5)删除一个学生的信息(需指定要删除学生的学号);同时显示删除后的结果。( 二) 功能需求分析 学生信息管理系统设计 学生信息包括:学号,姓名,性别,出生年月,电话 使之提供以下功能: 1、系统以菜单方式工作 2、建立链表并显示 3、插入新的学生信息 4、删除某学号的学生信息 5、查找某学号的学生信息 6、对学生信息排序 7、统计学生人数 8、输出学生信息 二总体设计 (一)模块 依据程序的数据结构,描述该程序的层次结构,如下图: 1、建立链表并显示 void createlist(struct stucode **r); 2、插入新的学生信息 void insert(struct stucode **r); 3、删除某学号的学生信息 void del(struct stucode **r); 4、查找某学号的学生信息 void search1(struct stucode *r); 5、对学生信息排序 void sort(struct stucode **r); 6、统计学生人数 void search2(struct stucode *r); 7、输出学生信息 void out(struct stucode *r); 1 建立链表并显示 2 添加学生信息 3 删除学生信息 息 4 按学号查找学生信 5 对学生信息排序 6统计学生人数 7输出学员信息 8 学生信息写入文件 0退出 main() 菜单函数 C程序设计课程设计 题目:学生选课系统专业班级:通信工程1班姓名: 学号: 指导教师: 成绩: 摘要 学生选课系统是一个教育单位不可缺少的重要系统组成部分,它对于学校的决策者、管理者管理、查看课程来说都有至关重要,所以学生选课管理系统应该能够为广大学、师生提供充足的信息和快捷的课程选择过程,有助于学生选好每一门课程,此系统系统选课方便、快捷,用简单的界面来展示学生的选课信息,应用简单明了、存储量大、可靠性高、保密性好、寿命长、成本低等优点,可以极大的提高对学生信息管理的效率。利用C语言开发,实现了简单的学生课程信息的录入、修改、查询、删除等操作,并且能够利用文件系统长久的保留原始数据。 目录 一、需求分析 (1) 二、总体设计 (1) 三、详细设计 (2) 1、数据定义...................................................... 错误!未定义书签。 2、算法流程图 (2) 四、编码 (6) 五、调试 (7) 六、设计总结 (10) 致谢 (11) 参考文献 (12) 附录 (13) 一、需求分析 语言文字描述系统要做什么 数据结构可用结构体,包括课程和选修两个结构体,其中课程结构体成员结构体成员包括课程编号,课程名称,课程性质,总学时,授课学时,实验或上机学时,学分,开课学期。选修结构体成员包括学号,课程编号,该结构体的建立主要是为了查询某门课程学生选修情况。 二、总体设计 系统由哪几个功能模块构成,给出功能模块图。C 中模块化的工具是函数 根据上面的需求分析,可以将这个系统的设计分为如下七大模块: 选课模块、按学分查找模块、按编号查找模块、查看课程模块、查看选课情况模块、课程输入模块、完成选择模块。 菜单选择模块 录入学生信息 学生选课 系统信息查看及储存 退出系统 完成选择模块 学生信息 管 理 录入课程信息 课程 管理 C语言课程设计题目 选题一(起评分100分) 高考招生录取程序 已知文本文件f1.txt中存放了某个省当年参加高考的1000个考生的数据(考号、姓名、性别和考试成绩),存放格式是每行存放一个考生的数据,每个数据之间用空格隔开。 假定当年该省的招生计划是:一类本科招生计划为10%;二类本科招生计划为15%;三类本科招生计划为20%;四类高职高专招生计划为25%。 请编写程序,实现以下功能: (1)划定各批次录取分数线,结果可屏幕显示,也可存入文件。 (2)能够统计各批次中男生,女生的录取比例。统计结果可屏幕显示,也可存入文件。 (3)确定每名学生的录取情况及录取批次。 (4)考生可以根据考号或姓名(支持重名)查询自己的成绩及录取情况; 说明: ①系统程序要有界面 ②存入文件的数据,每行存一种数据,每行之间的不同信息用空格分隔。 选题二(起评分85分) 《C语言课程设计与学习指导》第4章题目或第5章题目任选其一 成绩评定方式 平时考勤:20% 考试(即程序考核及检查):40% 实习报告:40% 违规违纪处理 出现以下6种情况中的任何一种,整个课程设计的成绩直接认定为不及格: 1.考勤抽查出现3次(含)不在的情况; 2.上机从事玩游戏、看电影等活动被抓住2次(含)的情况; 3.程序检查被认定为抄袭的情况; 4.实习报告被认定抄袭或雷同的情况; 5.不参加考试(即程序考核及检查)的情况 6.不交实习报告的情况。 C语言课程设计报告撰写要求 1 内容要求 整个报告由六个部分构成: ①课设题目 ②题目分析 ③设计思路 ④实现结果 ⑤课设总结 ⑥附录(源代码) 2 篇幅要求 ①-⑤合计不低于8页,⑥不低于8页。 篇幅没有上限要求,但原则上要求不超过25页。 标题字体字号格式:宋体,三号,加黑,单倍行距。 正文字体字号格式:宋体或Times New Roman,五号,单倍行距。 3 撰写要求 严谨出现抄袭。 严谨出现雷同。 报告出现抄袭或雷同的,整个课程设计成绩一律按不及格论处。 4 其它 封面格式附后。 #include void output();//输出格式 void paixu();//航班排序 void chushihua();//系统初始化 void build();//建立数据文件 void paixu1();//按航班号从小到大排序 void paixu2();//从大到小 void main()//主函数{int j; chushihua();//系统初始化判断是否存在原始数据文件 printf("欢迎使用飞机订票系统\n");//打印出系统主界面 do{printf("============================================================= =================== "); printf(" 1.增加航班信息\n" "\t 2.浏览航班信息\n" "\t\t 3.查找航班信息(按航班号)\t\t╮(╯_╰)╭\n" "\t\t\t 4.航班排序(按航班号)\n" "\t\t\t\t 5.订票业务\n" "\to(︶︿︶)o\t\t\t #i n c l u d e c语言课程设计源代码标准化管理处编码[BBX968T-XBB8968-NNJ668-MM9N] 学校运动会管理系统问题描述: (1) 初始化输入:N-参赛院系总数,M-男子竞赛项目数,W-女子竞赛项目数; (2) 各项目名次取法有如下几种: 取前5名:第1名得分 7,第2名得分 5,第3名得分3,第4名得分2,第5名得分 1; (3) 由程序提醒用户填写比赛结果,输入各项目获奖运动员的信息。 (4) 所有信息记录完毕后,用户可以查询各个院系或个人的比赛成绩,生成团体总分报表,查看参赛院系信息、获奖运动员、比赛项目信息等。 程序代码: #include<> #include<> #define N 3 #define M 3 #define W 3 char* n_number[3]={"1","院系2","院系3"}; char* m_number[3]={"1","男项2","男项3"};c语言课程设计机房机位预定系统绝对正确,附源代码
C语言课程设计报告——贪吃蛇源程序
C语言课程设计俄罗斯方块源代码
c语言课程设计报告学生成绩信息管理系统源代码
C语言课程设计---学生选课系统加源代码
中国地质大学C语言课程设计题目(附参考代码)
C语言课程设计――飞机订票系统源代码
c语言课程设计报告会员卡计费系统源代码
//编译预处理指令,引入头文件 #include c语言课程设计源代码