校际运动会管理系统报告+源代码张晶.docx
《校际运动会管理系统报告+源代码张晶.docx》由会员分享,可在线阅读,更多相关《校际运动会管理系统报告+源代码张晶.docx(25页珍藏版)》请在冰豆网上搜索。
校际运动会管理系统报告+源代码张晶
一、题目要求
设计校际运动会管理系统,实现学校、运动员信息和运动项目的录入,比赛结果的输入,各个学校比赛结果的查询,生成团体总分报表,查看参赛学校信息和比赛项目信息。
要求功能选择用菜单实现。
二、需求分析
根据题目要求应提供键盘式菜单实现功能选择,还应提供信息的输入操作,由于在程序中提供查询功能所以应有显示、查找等操作。
三、总体设计
根据上面的需求分析,可以将这个系统的设计分为1、信息输入模块2、比赛结果录入模块3、查询模块。
具体校际运动会管理系统分为信息的输入、结果的输入、学校各个项目的得分的查寻、总体报表的生成。
四、详细设计
1、主函数
主函数一般设计的比较简洁,只提供输入,处理和输出部分的函数调用。
其中功能模块用菜单方式选择。
流程图
↓
↓
N
Y
[程序]
main()
{
menu();/*menu是菜单函数*/
}
菜单函数程序如下:
menu()
{into,n;
do
{puts("\t\t*****************MENU********************");
puts("\n\n\t\t1.Theinformationtowritein\n");
puts("\t\t2.Theraceresultrecordstowritein\n");
puts("\t\t3.Searchtheinformation\n");
puts("\t\t4.Exit\n");
puts("\n\t\t*****************************************");
puts("\n\nChoiceyounumber:
");
scanf("%d",&n);
if(n<1||n>4){o=1;getchar();}/*对选择的数字进行判断*/
elseo=0;
}while(o==1);/*选择功能*/
switch(n)
{case1:
writein();break;/*信息输入模块*/
case2:
resultin();break;/*比赛结果输入模块*/
case3:
search();break;/*查询模块*/
case4:
exit(0);/*退出*/
}
}
各个模块的设计
1、信息输入
[数据结构]
数据结构采用结构体的形式,包括学校、项目、运动员三个结构体。
比如学校结构体成员包括学校校名、竞赛项目、得分;项目结构体成员包括项目名、权值。
structstudent
{charshool[10];
charname[10];
charitem[10];
charsex;
intposition;
intmark;
}stu[C];/*stu[N]中每个数组元素对应一个学生*/
structitem
{charname[10];
charsex;
intmark;
}it[C];/*it[C]中每个数组元素对应一个项目*/
structshool
{charname[10];
charitem[10];
intmark;
}sho[C]/*sho[C]每个数组元素对应一个学校;*/
[信息输入模块]
根据题意把与运动员的学校、名字、项目、性别、名次、分数作为结构体成员,如果要存放若干个运动员的信息就用结构体数组。
structstudent
{charshool[10];
charname[10];
charitem[10];
charsex;
intposition;
intmark;
}stu[C];/*stu[C]中每个数组元素对应一个运动员*/
stu[C]中的C为运动员的个数,程序中采用宏定义的方式定义C=100,C的值可随时在源程序中改变。
图2输入模块流程图
/******************输入模块*****************/
writein()/*输入模块*/
{intt,r,i=0;externj;charF,M;y=1;
printf("\nPleasewriteinthestudent'sname:
\t");scanf("%s",&stu[i].name);/*输入名字*/
printf("\nPleasewriteinthestudent'sshool:
\t");scanf("%s",&stu[i].shool);/*输入学校*/
printf("\nPleasewriteinthestudent'sitem:
\t");scanf("%s",&stu[i].item);/*输入项目*/
loop_1:
printf("\nPleasewriteinthestudent'ssex(WorM):
\t");scanf("%s",&stu[i].sex);/*输入性别*/
if(stu[i].sex!
='W'&&stu[i].sex!
='M')gotoloop_1;/*选择函数*/
printf("\nPleasewriteinthestudent'sposition:
\t");scanf("%d",&stu[i].position);
mark(j,i);
loop_2:
printf("\n\nDoagain?
\t1).Yes\t2).No\t");
scanf("%d",&t);
if(t!
=2&&t!
=1)gotoloop_2;/*调用goto结构*/
if(t==2)menu();
i++;
if(t==1);f=1;
printf("Success\nPressanykey+entertomenu..");scanf("%d",&r);/*返回主函数*/
menu();
}
[结果录入模块]
该模块的功能是输入男女运动员的成绩,并由用户选择或定义各名次的分数。
[流程图]
[程序]
/**********************结果录入模块*********************/
resultin()/******结果录入模块*****/
{inth,r;externN,M,W,y;
if(y==0)
{printf("Pleaseestablishsystemfirst!
!
\nPressanykey+entertomenu..");
scanf("%d",&r);/******提醒用户输入运动员的基本信息*******/
menu();
}
printf("\nThenumberofshoolattendedis:
");
scanf("%d",&N);
printf("\nThenumberofmenitemis:
");
scanf("%d",&M);
printf("\nThenumberofwomenitemis:
");
scanf("%d",&W);/****输入学校的代号、男女运动项目的代号****/
printf("\nTherearethreeformofmarkedyoucanchoice:
");
printf("\n\n\t1).1th--7,2th--5,3th--3,4th--2,5th--1.");
printf("\n\n\t2).1th--5,2th--3,3th--1.");
printf("\n\n\t3).Definebyyouself.");/*****用户自定义********/
loop:
printf("\n\nChoicethenumber(1--3):
");
scanf("%d",&h);
if(h>0&&h<4)
switch(h)
{case1:
j=1;break;
case2:
j=2;break;
case3:
define_mark();
}/*******选择积分模式*********/
elsegotoloop;/*******输入错误重新选择*******/
printf("Success\nPressanykey+entertomenu..");scanf("%d",&r);
menu();/*******返回主函数*******/
}
[查询模块]
该模块的功能是所有信息记录完毕后用户可以查询学校比赛成绩,查看参赛学校信息和比赛项目信息等。
[流程图]
[程序]
/*****************查询模块*****************/
search()
{inte;charc;externf;
loop:
printf("\nTheformofsearchingyouwanttochoice:
\n\t1).Byschool\n\t2).Btitem\n\t3).Tomenu\t");/************选择查询模式**************/
scanf("%d",&e);
switch(e)
{case1:
search_school();break;
case2:
search_item();break;
case3:
menu();
}
if(e>4||e<1)gotoloop;
printf("Pressanykey+entertomenu..");scanf("%s",&c);menu();
}
search_school()/**********学校查询程序***********/
{intx,sum=0,w=0;
structstudents;
printf("\nPleaseenterthenameoftheschoolthatyouwanttosearch:
");
scanf("%s",&s.shool);
printf_face();
for(x=0;xif(strcmp(s.shool,stu[x].shool)==0)/***********调用stu结构体************/
{sum+=stu[x].mark;
printf_one(x);w=1;
}/***********读出结构体的数据*********/
printf_sum(sum);
if(w==0)
{printf("\n\n*Thenameiswrong,pressagain!
");search_school();}
}
search_item()/*********项目查询程序********/
{intx,sum=0,w=0;
structstudents;
printf("\nPleaseenterthenameoftheitemthatyouwanttosearch:
");
scanf("%s",&s.item);
printf_face();/********数据输入*********/
for(x=0;xif(strcmp(s.item,stu[x].item)==0)/********调用stu数组******/
{sum+=stu[x].mark;
printf_one(x);w=1;
}
printf_sum(sum);/*******数据输出*********/
if(w==0)
{printf("\n\n*Thenameiswrong,pressagain!
");search_item();}
}
[程序中调用的函数]
记分的函数即用来确定不同的名次所得的不同分数。
mark(intj,inti)
{intg;externp[15],q[15];
if(j==1)
{if(stu[i].position==1)stu[i].mark=7;
elseif(stu[i].position==2)stu[i].mark=5;
elseif(stu[i].position==3)stu[i].mark=3;
elseif(stu[i].position==4)stu[i].mark=2;
elseif(stu[i].position==5)stu[i].mark=1;
}
if(j==2)
{if(stu[i].position==1)stu[i].mark=5;
elseif(stu[i].position==2)stu[i].mark=3;
elseif(stu[i].position==3)stu[i].mark=1;
}
if(j==3)
{for(g=0;g<15;g++)if(stu[i].position==p[g])stu[i].mark=q[g];}
}
define_mark()/*自定义名次分数的子函数*/
{staticintp[15],q[15],a,b,j;
for(a=0;a<15;a++)
{printf("\nTheposition(1--15):
");scanf("%d",&p[a]);
printf("\nThemarkyouwanttodefine(Integral):
");scanf("%d",&q[a]);/*自定义*/
loop:
printf("\nDoyouwantdefinemore:
\t1).Yes\t2).No");scanf("%d",&b);
if(b==2)break;
if(b!
=1)gotoloop;
}
j=3;
}
printf_one(intx)/*运动员个人信息的输出函数*/
{printf("\n%-20s%-20s%-20s%-5c%-9d%-5d",stu[x].shool,stu[x].name,stu[x].item,stu[x].sex,stu[x].position,stu[x].mark);
}
printf_sum(intsum)/*团体成绩的输出函数*/
{printf("\n\nThesumofmarkis:
\t%d",sum);
printf("\nTheshoolnumberis:
\t%d",N);
printf("\nTheitemnumberis:
\t%d\n",W+M);
}
printf_face()/**学校成绩输出函数*/
{printf("\n\nSchoolnamestudentnameitemsexpositionmark");
}
[原程序]
#include
#defineC100
inty=0,f=0,j,W,M,N,p[15],q[15];
structstudent
{charshool[10];
charname[10];
charitem[10];
charsex;
intposition;
intmark;
}stu[C];
structitem
{charname[10];
charsex;
intmark;
}it[C];
structshool
{charname[10];
charitem[10];
intmark;
}sho[C];
main()
{
menu();
}
menu()
{into,n;
do
{puts("\t\t*****************MENU********************");
puts("\n\n\t\t1.Theinformationtowritein\n");
puts("\t\t2.Theraceresultrecordstowritein\n");
puts("\t\t3.Searchtheinformation\n");
puts("\t\t4.Exit\n");
puts("\n\t\t*****************************************");
puts("\n\nChoiceyounumber:
");
scanf("%d",&n);
if(n<1||n>4){o=1;getchar();}
elseo=0;
}while(o==1);
switch(n)
{case1:
writein();break;
case2:
resultin();break;
case3:
search();break;
case4:
exit(0);
}
}
writein()
{intt,r,i=0;externj;charF,M;y=1;
printf("\nPleasewriteinthestudent'sname:
\t");scanf("%s",&stu[i].name);
printf("\nPleasewriteinthestudent'sshool:
\t");scanf("%s",&stu[i].shool);
printf("\nPleasewriteinthestudent'sitem:
\t");scanf("%s",&stu[i].item);
loop_1:
printf("\nPleasewriteinthestudent'ssex(WorM):
\t");scanf("%s",&stu[i].sex);
if(stu[i].sex!
='W'&&stu[i].sex!
='M')gotoloop_1;
printf("\nPleasewriteinthestudent'sposition:
\t");scanf("%d",&stu[i].position);
mark(j,i);
loop_2:
printf("\n\nDoagain?
\t1).Yes\t2).No\t");
scanf("%d",&t);
if(t!
=2&&t!
=1)gotoloop_2;
if(t==2)menu();
i++;
if(t==1);f=1;
printf("Success\nPressanykey+entertomenu..");scanf("%d",&r);
menu();
}
resultin()
{inth,r;externN,M,W,y;
if(y==0)
{printf("Pleaseestablishsystemfirst!
!
\nPressanykey+entertomenu..");
scanf("%d",&r);
menu();
}
printf("\nThenumberofshoolattendedis:
");
scanf("%d",&N);
printf("\nThenumberofmenitemis:
");
scanf("%d",&M);
printf("\nThenumberofwomenitemis:
");
scanf("%d",&W);
printf("\nTherearethreeformofmarkedyoucanchoice:
");
printf("\n\n\t1).1th--7,2th--5,3th--3,4th--2,5th--1.");
printf("\n\n\t2).1th--5,2th--3,3th--1.");
printf("\n\n\t3).Definebyyouself.");
loop:
printf("\n\nChoicethenumber(1--3):
");
scanf("%d",&h);
if(h>0&&h<4)
switch(h)
{case1:
j=1;break;
case2:
j=2;break;
case3:
define_mark();
}
elsegotoloop;
printf("Success\nPressanykey+entertomenu..");scanf("%d",&r);
menu();
}
search()
{inte;charc;externf;
loop:
printf("\nTheformofsearchingyouwanttochoice:
\n\t1).Byschool\n\t2).Btitem\n\t3).Tomenu\t");
scanf("%d",&e);
switch(e)
{case1:
search_school();break;
case2:
search_item();break;
case3:
menu();
}
if(e>4||e<1)gotoloop;
printf("Pressanykey+entertomenu..");scanf("%s",&c);menu();
}
search_school()
{intx,sum=0,w=0;
structstudents;
printf("\nPleaseenterthenameoftheschoolthatyouwanttosearch:
");
scanf("%s",&s.shool);
printf_face();
for(x=0;xif(strcmp(s.shool,stu[x].shool)==0)
{sum+=stu[x].mark;
printf_one(x);w=1;
}
printf_sum(sum);
if(w==0)
{printf("\n\n*Thenameiswrong,pressagain!
");search_school();}
}
search_item()
{intx,sum=0,w=0;
structstudents;
printf("\nPleaseenterthenameoftheitemthatyouwanttosearch:
");
scanf("%s",&s.item);
printf_face();
for(x=0;xif(strcmp(s.item,stu[x].item)==0)
{sum+=stu[x].mark;
printf_one(x);w=