一、用文件存储一场比赛的统计数据,如:
Thunder 109:113 Rocket
Westbrook,38,21,9,9,4
Geogre,38,28,14,2,4
。。。。
其中第一行表示比赛总比分;后面每行表示一个球员的各项统计数据,如第一行表示Westbrook,上场38分钟,得分21分,篮板数为9,助攻数为9,抢断数为4,各项数据间用逗号隔开。
要求:
1、读取文件中的各个球员的统计数据
(可以用结构体来存储一个球员的所有数据);
2、用户可以选择不同的统计项来查看数据,如:
得分榜(按球员得分从高到底排序)
助攻榜(按球员助攻从高到底排序)
抢断榜(按球员抢断从高到底排序)
根据加权规则计算球员的效率:
得分比重为1,篮板比重为2,助攻为2,抢断为5,则球员效率值=加权总得分/总上场时间。如Westbrook的效率值为:
(21*1+9*2+9*2+4*5)/38=77/38=2.02
用户选择查看球员效率值后,输出所有上场球员的效率值。
扩展:
如果有多个文件,每个文件存储一场比赛的统计数据,计算多场比赛的球员数据,注意此时各项数据为多场比赛的平均值,如球员的得分,为多场比赛的每场平均分。
#include
#include
//队伍信息
struct Team{
char teamname[10];
int General_points;
int ate;
char are[10];
}team[10],team_2[10];
//球员信息
struct Count{
char name[10];
int time;//时间
int score;//得分
int backboard;//篮板数
int Assisted_number;//助攻数
int Steal_number; //抢断数
double efficient_number;//效率值
}count[10],count_2[10];
int n=-1;
int n2=-1;
//函数声明
struct Count* inputNBAnumber(struct Count *p,int k);
struct Count* inputNBAnumber2(struct Count *p,int k) ;
void score_list(struct Count count[10],int len);
void Assists_list(struct Count count[10],int n);
void Steal_list(struct Count count[10],int n);
void Look(struct Count count[10],int n,int l);
void efficient(struct Count count[10],int n);
void number_NBA();
void number_NBA2();
int main()
{
FILE* fp = fopen("D:\