C语言课程设计~~~ 要求编写一段程序,题目是《校际运动会管理系统》

要求:初始化输入:N-参赛学校总数,M-男子竞赛项目数,W-女子竞赛项目数
各项目名次取法有如下几种:
取前5名:第一名得分7分,第二名得分5,第三名得分3,第四名得分2,第五名得分1;取前3名:第一名得分5,第二名得分3,第三名得分2;
用户自定义:各名次权值由用户指定。2由程序提醒用户填写比赛结果,输入各项目获奖运动员信息。3所有信息记录完毕后,用户可以查询各个学校的比赛成绩,生成团体总分报表,查看参赛学校信息和比赛项目信息等。希望各位高手可以提供尽量符合大一学生的作品。

我这是源代码已经调试过了,在VC++上运行成功了。
#include "stdio.h" /*I/O函数*/
#include "stdlib.h" /*其它说明*/
#include "string.h" /*字符串函数*/
#include "conio.h" /*屏幕操作函数*/
#include "mem.h" /*内存操作函数*/
#include "ctype.h" /*字符操作函数*/
#include "alloc.h" /*动态地址分配函数*/
struct score
{
int mingci;
char xuehao[8];
char mingzi[20];
float score[6];
}data,info[1000];
int i,j,k=0;
char temp[20],ch;
FILE *fp,*fp1;

void shuru()
{
if((fp=fopen("s_score.txt","ab+"))==NULL)
{
printf("cannot open this file.\n");
getch();exit(0);
}
for(i=0;i<=1000;i++)
{
printf("\nPlease shuru xuehao:");
gets(data.xuehao);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please shuru wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please shur huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];
fwrite(&data,sizeof(data),1,fp);
printf("another?y/n");
ch=getch();
if(ch=='n'||ch=='N')
break;
} fclose(fp);
}
void xianshi()
{
float s;int n;
if((fp=fopen("s_score.txt","rb+"))==NULL)
{
printf("Cannot reading this file.\n");
exit(0);
}
for(i=0;i<=1000;i++)
{
if((fread(&info[i],sizeof(info[i]),1,fp))!=1)
break;
}
printf("\nxuehao mingzi yuwen shuxue yingyu wuli huauxue zhongfen\n");
for(j=0,k=1;j<i;j++,k++)
{
info[j].mingci=k;
printf("%6s %8s %3.1f %3.1f %3.1f %3.1f %3.1f %3.1f\n",info[j].xuehao,info[j].mingzi,info[j].score[0],info[j].score[1],info[j].score[2],info[j].score[3],info[j].score[4],
info[j].score[5]);
}
getch();
fclose(fp);
}

void xiugai()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("Cannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xiugai xuehao:");
scanf("%d",&i); getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{
printf("xuehao:%s\nmingzi:%s\n",data.xuehao,data.mingzi);
printf("Please shuru mingzi:");
gets(data.mingzi);
printf("Please shuru yuwen score:");
gets(temp);data.score[0]=atof(temp);
printf("Please shuru shuxue score:");
gets(temp);data.score[1]=atof(temp);
printf("Please input yingyu score:");
gets(temp);data.score[2]=atof(temp);
printf("Please input wuli score:");
gets(temp);data.score[3]=atof(temp);
printf("Please input huaxue score:");
gets(temp);data.score[4]=atof(temp);
data.score[5]=data.score[0]+data.score[1]+data.score[2]+data.score[3]+data.score[4];

} fwrite(&data,sizeof(data),1,fp1);
}
fseek(fp,0L,0);
fseek(fp1,0L,0);
while((fread(&data,sizeof(data),1,fp1))==1)
{
fwrite(&data,sizeof(data),1,fp);
}

fclose(fp);
fclose(fp1);
}
void chazhao()
{
if((fp=fopen("s_score.txt","rb"))==NULL)
{
printf("\nCannot open this file.\n");
exit(0);
}
printf("\nPLease shuru xuehao chakan:");
scanf("%d",&i);
while(fread(&data,sizeof(data),1,fp)==1)
{
j=atoi(data.xuehao);
if(i==j)
{
printf("xuehao:%s mingzi:%s\nyuwen:%f\n shuxue:%f\n yingyu:%f\n wuli:%f\n huaxue:%f\n ",data.xuehao,data.mingzi,data.score[0],data.score[1],data.score[2],data.score[3],data.score[4],data.score[5]);
}getch();
}
}
void shanchu()
{
if((fp=fopen("s_score.txt","rb+"))==NULL||(fp1=fopen("temp.txt","wb+"))==NULL)
{
printf("\nopen score.txt was failed!");
getch();
exit(0);
}
printf("\nPlease input ID which you want to del:");
scanf("%d",&i);getchar();
while((fread(&data,sizeof(data),1,fp))==1)
{
j=atoi(data.xuehao);
if(j==i)
{

printf("Anykey will delet it.\n");
getch();
continue;
}
fwrite(&data,sizeof(data),1,fp1);
}
fclose(fp);
fclose(fp1);
remove("s_score.txt");
rename("temp.txt","s_score.txt");
printf("Data delet was succesful!\n");
printf("Anykey will return to main.");
getch();
}
main()
{
while(1)
{
clrscr(); /*清屏幕*/
gotoxy(1,1); /*移动光标*/
textcolor(YELLOW); /*设置文本显示颜色为黄色*/
textbackground(BLUE); /*设置背景颜色为蓝色*/
window(1,1,99,99); /* 制作显示菜单的窗口,大小根据菜单条数设计*/
clrscr();
printf("*************welcome to use student manage******************\n");
printf("*************************menu********************************\n");
printf("* ========================================================= * \n");
printf("* 1>shuru 2>xiugai * \n");
printf("* 3>shanchu 4>chazhao * \n");
printf("* 5>xianshi 6>exit * \n");
printf("* * \n");
printf("* --------------------------------------------------------- * \n");
printf(" Please input which you want(1-6):");
ch=getch();
switch(ch)
{
case '1':shuru();break;
case '2':xiugai(); break;
case '3':shanchu(); break;
case '4':chazhao(); break;
case '5':xianshi(); break;
case '6':exit(0);
default: continue;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-06-16
设定姓名长度不超过20字符。每个项目结束时,将其编号、类型符(区分取前3名还是前5名)输入,并按名次顺序输入运动员姓名、学校和成绩。程序已做改动,增加了一些代码以提高程序的健壮性。
本题完整的c程序如下,在win-tc和Dev-c++下调试通过,运行正确。
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <conio.h>
#define n 5 /*设定,可更改*/
#define m 3 /*设定,可更改*/
#define w 2 /*设定,可更改*/

struct achievement /* 定义表示成绩的结构体 */
{int schoolnumber;/* 学校编号 */
char name[20]; /* 姓名 */
int mark; /* 分数 */
int result;};

struct pro /* 表示项目的结构体 */
{int tag;/* 项目编号 */
struct achievement ach[m+w];
int number;
};

struct Node
{struct pro date;
struct Node *next;
};

main()
{
int i,j,t;
int x[n]={0};int y[n]={0}; /* x[n]和y[n]分别表示男子和女子团体总分 */
struct Node *head;
struct Node *p;
struct Node *q;
if((head=(struct Node*)malloc(sizeof(struct Node)))==NULL) exit(1);
head->next=NULL; /* 初始化单链表 */
p=head;
for(i=0;i<m+w;i++) /* 输入成绩 */
{
j=i+1;
printf("请输入第%d个项目的信息\n",j);
p->date.number=j;
printf("所取的名次数为:");
scanf("%d",&p->date.tag);
while(p->date.tag!=3&&p->date.tag!=5)
{ printf("输入有误,请重新输入!");
getchar(); /*加入此函数清空输入缓冲区,避免输入错误时程序进入无限循环*/
getchar();
printf("所取的名次数为:");
scanf("%d",&p->date.tag);
}
t=1;
while(t<=p->date.tag)
{
printf("第%d名的名字:",t);
scanf("%s",p->date.ach[t-1].name);
printf("第%d名的学校:",t);
scanf("%d",&p->date.ach[t-1].schoolnumber);
printf("第%d名的分数:",t);
scanf("%d",&p->date.ach[t-1].mark);
p->date.ach[t-1].result=t;
t++;
}
if(j!=m+w)/* 注意这里 */
{q=(struct Node*)malloc(sizeof(struct Node)); /* 生成新结点 */
p->next=q;
p=q;
p->next=NULL;
}
}
for(i=0;i<n;i++) /* 产生成绩单 */
{
j=i+1;
printf("\n学校%d成绩单:\n",j);
p=head;
while(p!=NULL)
{
t=1;
while(t<=p->date.tag)
{
if(p->date.ach[t-1].schoolnumber==j)
{
printf("获奖项目:%d ",p->date.number);
printf("名次:%d ",p->date.ach[t-1].result);
printf("获奖人姓名:%s ",p->date.ach[t-1].name);
printf("所得分数:%d \n",p->date.ach[t-1].mark);
if(p->date.number<=m)
x[i]=x[i]+p->date.ach[t-1].mark;
else
y[i]=y[i]+p->date.ach[t-1].mark;
}
t++;
}
p=p->next;
}
printf("\n男子团体总分:%d ",x[i]);
printf("女子团体总分:%d \n",y[i]);
printf("团体总分:%d\n",x[i]+y[i]);
}
for(i=0;i<m+w;i++) /*释放申请的内存空间*/
{p=head->next;
free(head);
head=p;
}
getch();
}

参考资料:http://zhidao.baidu.com/question/79204562.html

第2个回答  2009-06-23
课程设计任务书

一、题目:
十佳运动员评选活动。
二、 系统设计要求
1.充分理解课程设计的目的和意义
有一个寓言叫庖丁解牛,讲的是一个叫庖丁的人,在开始学宰牛时,因为不了解牛的身体构造,眼前所见无非就是一头头庞大的牛。等他有了三年的宰牛经历后,就完全了解了牛的构造。再看牛时,出现在眼前的就不再是一头整牛,而是许多可以拆卸下来的零部件!
编成也是一样的,在没深入学习之前,总觉得别人的程序写得好,自己编又总觉得无从下手。所谓胸有成竹,意在笔先,我们认为可以通过读程序来培养“意”念。在进行本课程设计时,希望能够首先学会对程序的功能进行解构,因为如果不了解程序的需求就贸然下手,见到的必然是一条庞大的“牛”。在此基础上,如果能够进一步掌握编程的逻辑思维方式,注意结构化的程序设计、数据结构的选择、算法的实现……看到的将不再是一条条语句,而是一个个函数和功能模块了。当然要像庖丁一样,不用眼睛看,烂熟于心,还需要在长期的学习中反复实践、观察、分析、比较、总结,逐渐地积累和提高。
2. 功能要求
某市体委与电视台联合举办十佳运动员有奖评选活动,具体说明如下:
(1)体委组织有关人士评出了如表1所示的20个候选人名单。
运动员编号 运动员姓名 运动员编号 运动员姓名
01 小明 … …
02 小翔 20 小丹
(2)电视台在网上设立了投票站供市民投票,以便用计算机进行统计和核对。选票格式如表2所示。
选票编号 0000001
投票人姓名 投票人地址
拟选运动员编号
选票号为7位数字,有效的运动员编号是01~20。
(3)计算机统计的具体任务是:
① 统计出各候选人的得票数,并根据得票数排定名次,选出十佳人员。
② 根据命中率选出10个获奖的参选者,并排定名次。
命中率=命中分+次序分
命中分:选中十佳中的一个即得10分,选中n个得n╳10分(不考虑次序)。
次序分:选票中的第一个运动员与十佳中的第一名相符(简称选中第一名)得9分,选中第二名得8分,……,选中第十名的0分。
(4)编写出完成以上统计任务的程序。
具体要求如下:
① 候选人数据和选票数据应以文本文件的方式分别存放在两个文件中,选票中参选人的地址可以不考虑。
② 程序中,对选票数据要求采用结构体作数据结构。
③ 程序除能完成统计功能外,应具有核对选票数据的功能,并且每一功能的实现要采用选择菜单的方式进行(使用简单的文本菜单),菜单至少包含以下几项:
a. 统计
b. 核对选票
c. 退出
④ 程序和数据中不提倡使用汉字,相应的地方用英文代替。
⑤ 各大功能和各个相对独立的任务要求编写成独立的函数,主函数只用于管理菜单和组织调用个功能函数。
⑥ 统计结果除在屏幕显示外,还要求输出到文件中。
三、要求
1. 设计任务在2009年6月22日——2009年7月3日二周内完成。
2. 设计成果包括《十佳运动员评选》源代码一份,设计报告一份。
3. 设计成果必须于2009年7月3日前上交。
四、设计报告编写提纲
1. 设计的内容介绍;
2. 设计的相关专业知识、技术说明;
3. 完成的步骤和实现效果;
4. 关键代码及注释;
5. 设计总结。
五、设计成绩评定依据
1. 完成效果50%;
2. 设计报告35%;
3. 考勤15%;
六、时间安排
第一阶段(2009.6.22—2009.6.24):收集资料、查阅参考书,相关知识准备;
第二阶段(2009.6.25—2009.7.1):上机实现
第三阶段(2009.7.1—2009.7.3):集成功能测试,完成上交材料
七、参考文献
《C语言程序设计》 中国铁道出版社
网络资源
八、时间安排
教师指导时间 时段 地点
18周6月23日 星期二 8:00-11:50;2:00-4:00 二机房
18周6月24日 星期三 8:00-11:50 二机房
19周6月30日 星期二 8:00-11:50;2:00-4:00 二机房
19周7月2日 星期四 8:00-11:50 二机房
第3个回答  2009-06-24
上面两个答案一个在vc上有错,一个没查询功能
相似回答