体育打分系统课程设计.docx
- 文档编号:28256047
- 上传时间:2023-07-09
- 格式:DOCX
- 页数:22
- 大小:211.03KB
体育打分系统课程设计.docx
《体育打分系统课程设计.docx》由会员分享,可在线阅读,更多相关《体育打分系统课程设计.docx(22页珍藏版)》请在冰豆网上搜索。
体育打分系统课程设计
体育打分系统
一、课题内容和要求
该程序适用于体育评委打分竞赛。
要求:
(1)系统可针对不同的竞技项目;
(2)可查询各裁判员打分的明细;
(3)能给出运动员的排名、打分情况等;
(4)运动员的基本信息保存于数据库中;
(5)裁判可直接选取某选手,对其打分;
(6)可查询打分规则;
(7)用VC++实现系统,要求界面简洁美观。
目的:
避免运动项目中手工计分的繁琐劳动及容易出错的情况,简单易用。
二、需求分析
1.引用了哪些函数
intGetRecord(FILE*fpt,structAthleteScore*sturecord)/*从指定文件读入一个记录*/
voidPutRecord(FILE*fpt,structAthleteScore*sturecord)/*对指定文件写入一个记录*/
voidShowAthleteRecord(structAthleteScore*rpt)/*显示运动员记录*/
voidListathleteinfo(char*fname)/*列表显示运动员成绩*/
structLinkNode*CreatLinklist(char*fname)/*构造链表*/
voidOutputLinklist(structLinkNode*h)/*顺序显示链表各表元*/
intSearchbyName(char*fname,char*key)/*按运动员姓名查找记录*/
intSearchbyCode(char*fname,char*key)/*按运动员号码查找记录*/
voidInsertRecord()
intmain()
{
{
system("cls");
printf("\n--------------Inputacommand-----------\n");
printf("|i:
insertrecordtoafile.|\n");
printf("|n:
searchrecordbyname.|\n");
printf("|c:
searchrecordbycode.|\n");
printf("|l:
listalltherecords.|\n");
printf("|s:
sorttherecordsbytotal.|\n");
printf("|q:
quit.|\n");
printf("------------------------------------------\n");
printf("Pleaseinputacommand:
\n");
scanf("%c",&c);/*输入选择命令*/
}
2创建了几个结构体
charjudgement[JUDEGNUM][NAMELEN+1]={"judgementA","judgementB","judgementC"};
structAthleteScore
{
charname[NAMELEN+1];/*姓名*/
charcode[CODELEN+1];/*学号*/
intscore[JUDEGNUM];/*各裁判给的成绩*/
inttotal;/*总成级*/
};
structLinkNode
{
charname[NAMELEN+1];/*姓名*/
charcode[CODELEN+1];/*号码*/
intscore[JUDEGNUM];/*各裁判给的成绩*/
inttotal;/*总成级*/
structLinkNode*next;
}*head;/*链表首指针*/
3、概要设计
1.intGetRecord(FILE*fpt,structAthleteScore*sturecord)
2.voidPutRecord(FILE*fpt,structAthleteScore*sturecord)
3.voidShowAthleteRecord(structAthleteScore*rpt)
4.intSearchbyCode(char*fname,char*key)
5.structLinkNode*CreatLinklist(char*fname)
6.voidInsertRecord()
7.intmain()
4、详细设计
#include
#include
#include
#include
#include
#defineJUDEGNUM3/*裁判数*/
#defineNAMELEN20/*姓名最大字符数*/
#defineCODELEN10/*号码最大字符数*/
#defineFNAMELEN80/*文件名最大字符数*/
#defineBUFFSIZE128/*缓冲区最大字符数*/
charjudgement[JUDEGNUM][NAMELEN+1]={"judgementA","judgementB","judgementC"};
structAthleteScore
{
charname[NAMELEN+1];/*姓名*/
charcode[CODELEN+1];/*学号*/
intscore[JUDEGNUM];/*各裁判给的成绩*/
inttotal;/*总成级*/
};
structLinkNode
{
charname[NAMELEN+1];/*姓名*/
charcode[CODELEN+1];/*号码*/
intscore[JUDEGNUM];/*各裁判给的成绩*/
inttotal;/*总成级*/
structLinkNode*next;
}*head;/*链表首指针*/
inttotal[JUDEGNUM];/*各裁判给的总成绩*/
FILE*filepoint;/*文件指针*/
charfilename[FNAMELEN];/*文件名*/
/*从指定文件读入一个记录*/
intGetRecord(FILE*fpt,structAthleteScore*sturecord)
{
charbuf[BUFFSIZE];
inti;
if(fscanf(fpt,"%s",buf)!
=1)
return0;/*文件结束*/
strncpy(sturecord->name,buf,NAMELEN);
fscanf(fpt,"%s",buf);
strncpy(sturecord->code,buf,CODELEN);
for(i=0;i fscanf(fpt,"%d",&sturecord->score[i]); for(sturecord->total=0,i=0;i sturecord->total+=sturecord->score[i]; return1; } /*对指定文件写入一个记录*/ voidPutRecord(FILE*fpt,structAthleteScore*sturecord) { inti; fprintf(fpt,"%s\n",sturecord->name); fprintf(fpt,"%s\n",sturecord->code); for(i=0;i fprintf(fpt,"%d\n",sturecord->score[i]); return; } /*显示运动员记录*/ voidShowAthleteRecord(structAthleteScore*rpt) { inti; printf("\nName: %s\n",rpt->name); printf("Code: %s\n",rpt->code); printf("score: \n"); for(i=0;i printf("%-15s: %4d\n",judgement[i],rpt->score[i]); printf("Total: %4d\n",rpt->total); } /*列表显示运动员成绩*/ voidListathleteinfo(char*fname) { FILE*fp; structAthleteScores; system("cls"); if((fp=fopen(fname,"r"))==NULL) { printf("Can'topenfile%s.\n",fname); return; } while(GetRecord(fp,&s)! =0) { ShowAthleteRecord(&s); } fclose(fp); return; } /*构造链表*/ structLinkNode*CreatLinklist(char*fname) { FILE*fp; structAthleteScores; structLinkNode*p,*u,*v,*h; inti; if((fp=fopen(fname,"r"))==NULL) { printf("Can'topenfile%s.\n",fname); returnNULL; } h=NULL; p=(structLinkNode*)malloc(sizeof(structLinkNode)); while(GetRecord(fp,(structAthleteScore*)p)! =0) { v=h; while(v&&p->total<=v->total) { u=v; v=v->next; } if(v==h) h=p; else u->next=p; p->next=v; p=(structLinkNode*)malloc(sizeof(structLinkNode)); } free(p); fclose(fp); returnh; } /*顺序显示链表各表元*/ voidOutputLinklist(structLinkNode*h) { system("cls"); while(h! =NULL) { ShowAthleteRecord((structAthleteScore*)h); printf("\n"); while(getchar()! ='\n'); h=h->next; } return; } /*按运动员姓名查找记录*/ intSearchbyName(char*fname,char*key) { FILE*fp; intc; structAthleteScores; system("cls"); if((fp=fopen(fname,"r"))==NULL) { printf("Can'topenfile%s.\n",fname); return0; } c=0; while(GetRecord(fp,&s)! =0) { if(strcmp(s.name,key)==0) { ShowAthleteRecord(&s); c++; } } fclose(fp); if(c==0) printf("Theathlete%sisnotinthefile%s.\n",key,fname); return1; } /*按运动员号码查找记录*/ intSearchbyCode(char*fname,char*key) { FILE*fp; intc; structAthleteScores; system("cls"); if((fp=fopen(fname,"r"))==NULL) { printf("Can'topenfile%s.\n",fname); return0; } c=0; while(GetRecord(fp,&s)! =0) { if(strcmp(s.code,key)==0) { ShowAthleteRecord(&s); c++; break; } } fclose(fp); if(c==0) printf("Theathlete%sisnotinthefile%s.\n",key,fname); return1; } voidInsertRecord() { FILE*fp; charc,i,j,n; structAthleteScores; system("cls"); printf("Pleaseinputtheathletesscorerecordfile'sname: \n"); scanf("%s",filename); if((fp=fopen(filename,"r"))==NULL) { printf("Thefile%sdoesn'texit.\ndoyouwanttocreatit? (Y/N)",filename); getchar(); c=getchar(); if(c=='Y'||c=='y') { fp=fopen(filename,"w"); printf("Pleaseinputtherecordnumber: "); scanf("%d",&n); for(i=0;i { printf("Inputtheathlete'sname: "); scanf("%s",&s.name); printf("Inputtheathlete'scode: "); scanf("%s",&s.code); for(j=0;j { printf("Inputthe%smark: ",judgement[j]); scanf("%d",&s.score[j]); } PutRecord(fp,&s); } fclose(fp); } } fclose(fp); return; } intmain() { inti,j,n; charc; charbuf[BUFFSIZE]; while (1) { system("cls"); printf("\n--------------Inputacommand-----------\n"); printf("|i: insertrecordtoafile.|\n"); printf("|n: searchrecordbyname.|\n"); printf("|c: searchrecordbycode.|\n"); printf("|l: listalltherecords.|\n"); printf("|s: sorttherecordsbytotal.|\n"); printf("|q: quit.|\n"); printf("------------------------------------------\n"); printf("Pleaseinputacommand: \n"); scanf("%c",&c);/*输入选择命令*/ switch(c) { case'i': InsertRecord(); getch(); break; case'n': /*按运动员的姓名寻找记录*/ printf("Pleaseinputtheathlete'sname: \n"); scanf("%s",buf); SearchbyName(filename,buf); getch(); break; case'c': /*按运动员的号码寻找记录*/ printf("Pleaseinputtheathlete'scode: \n"); scanf("%s",buf); SearchbyCode(filename,buf); getch(); break; case'l': /*列出所有运动员记录*/ Listathleteinfo(filename); getch(); break; case's': /*按总分从高到低排列显示*/ if((head=CreatLinklist(filename))! =NULL) OutputLinklist(head); getch(); break; case'q': return1; default: break; } } return1; } 5、测试数据及其结果分析(格式: 宋体,4号,加粗,两端对齐) 1.进行i操作: insertrecordtoafile.建立一个名为chusai的文件。 2.进行n操作: searchrecordbyname. 3.进行c操作: searchrecordbycode. 4.进行l操作: listalltherecords. 5进行w操作: theoutputraterules. 6.进行s操作: sorttherecordsbytotal. 6、调试过程中的问题 1.问题: 在编写程序时,分别经历了以下过程,对其修改: /*顺序显示链表各表元*/ voidOutputLinklist(structLinkNode*h) { system("cls"); while(h! =NULL) { ShowAthleteRecord((structAthleteScore*)h); printf("\n"); while(getchar()! ='\n'); h=h->next; } return; } 2.对程序的运行上的认识: 在文件的查询时,如果该文件已经存在,者对其的修改是不可逆的,只能进行查找,看等其他操作,因为是为了比赛数据的真实性,防止被人篡改,保证对比赛的公平,公正。 7、参考文献和查阅的资料(给出文献名或者网络链接) 1.在写程序时参考了这个: 2.《数据结构与算法》彭军向毅编著(人民邮电出版社) 3.在写程序时参考了这个: 4.在写程序时参考了这个: 8、程序设计总结 1.经过一周的课程设计,我学到了很多东西: ①巩固和加深了对数据结构的理解,提高综合运用本课程所学知识的能力。 ②培养了我选用参考书,查阅手册及文献资料的能力。 培养独立思考,深入研究,分析问题、解决问题的能力。 ③过实际编译系统的分析设计、编程调试,掌握应用软件的分析方法和工程设计方法。 ④够按要求编写课程设计报告书,能正确阐述设计和实验结果,正确绘制系统和程序框图。 ⑤通过课程设计,培养了我严肃认真的工作作风,逐步建立正确的生产观念、经济观念和全局观念。 课程设计是把我们所学的理论知识进行系统的总结并应用于实践的良好机会,有利于加强我们用知识理论来分析实际问题的能力,进而加强了我们对知识认识的实践度,巩固了我们的理论知识,深化了对知识的认识,并为走向社会打下一个良好的基础。 2.心得: 在进行程序编写时,要了解其原理,利用网络,很多代码都可以套用,但一定要知道原理,然后进行合理的利用,会给自己的编程中带来许多方便。 在平时中,要多进行练习,正所谓: 熟能生巧。 最后,团队合作的力量很大,大家在编程时互相帮助,共同进步;感谢老师在课程设计中的帮助。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 体育 打分 系统 课程设计
![提示](https://static.bdocx.com/images/bang_tan.gif)