运动会奖牌榜 C语言编程

运动会奖牌榜 C语言编程,第1张

用C语言或C++编写程序实现"运动会奖牌榜"问题!

(老师明天就要验收了,请各位大侠帮忙!满意的追加最多分,小弟不胜感激,先谢过啦!!!)

题目要求如下:

某综合性运动会设若干单项比赛,有多支参赛团体,每项比赛设金、银、铜牌奖,无并列奖项,前8名分别获得8~1分,计入团体总分。请实现以下功能:

1. 参赛队伍注册,其中队伍名称不能重复,一旦比赛开始(有成绩录入视为比赛开始),将不允许再注册;

2. 比赛项目管理,其中运动项目不能重复;

3. 比赛成绩录入,必须按注册队伍以及注册参赛项目录入,每名次唯一;

4. 输出奖牌榜,基本规则为金牌数多名次优先,金牌数相等则比较银牌数,银牌数相同则比较铜牌数,如全部相等则为并列名次,并按表格形式打印。

5. 输出团体总分榜,当团体总分相同,则按奖牌总数排名,否则为并列名次,并按表格形式打印。

6. 输出各单项成绩表,并按表格形式打印。

提示:

(1) 参赛团队数据结构设计需要满足的要求为登记参赛团队,满足参赛项目注册、成绩录入、奖牌榜以及团体总分榜输出的要求;比赛项目数据结构设计的目的是为各运动队伍进行参赛项目注册以及记录该项目最终比赛成绩提供查询支持;参赛项目注册是为了保证录入数据的合法性,未报名参赛的队伍和运动项目不能录入比赛成绩。

(2) 当在不同运动会使用相同的系统时,采用链表方式比采用数组方式更具通用性,因为链表可以满足动态存储的要求。数据结构输入后将需要使用文件方式保存。

该数据结构设计具有数据库管理系统的雏形,考虑到文本文件 *** 作上的不便性,该数据结构不考虑数据的删除和修改功能。

我这是源代码已经调试过了,在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=0i<=1000i++)

{

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 sint n

if((fp=fopen("s_score.txt","rb+"))==NULL)

{

printf("Cannot reading this file.\n")

exit(0)

}

for(i=0i<=1000i++)

{

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=1j<ij++,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>shuru2>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

}

}

对于专业的人来说 应该没问题(在没有权限的前提下) 通过查看源代码找到form表单 找 action 这个就是服务器处理页面 同时也会返回是否正确的答案 !

对于非专业人士来说 就不咋好弄了..


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9984159.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存