Home > Back-end >  Turn the Java for VB
Turn the Java for VB

Time:09-17

To deal with the results score: contestant n (n> 1), the judges m (m> 2), the judges give each player a score score (the score score for a positive number less than or equal to 10), the final score of contestant lastScore calculation method for
(1) m<9时,去掉一个最高分和一个最低分后另m-2个得分的平均值,(2)m≥9时,去掉两个最高分和两个最低分后另m-4个得分的平均值,假设事先已经建立了text型的数据文件f1.txt,其中依次记录着n个选手的编号(一个正整数),姓名(一个字符串)以及m个评委给出的得分,请编制程序,依次从数据文件f1.txt中读入n个选手的有关信息,而后按上述规定方法计算出每一个选手的最后得分,而且往屏幕上以及另一个text型文件f2.txt中同时输出如下形式的结果信息,假设参赛选手人数n=5,评委人数m=7,磁盘文件f1.txt中的初始数据为:1 zhangjin 8.8 9.3 7.9 8.7 8.9 9.7 9.22 lintao 8.9 8.2 8.6 8.8 8.5 9.1 9.33 guojian 8.9 8.4 8.7 8.6 8.6 8.4 8.64 maling 7.9 8.3 8.5 8.6 8.5 8.9 8.35 liuyifan 9.5 9.1 9.8 9.2 9.0 9.5 8.9那么,程序执行后,屏幕显示结果以及磁盘文件f2.txt中的结果均应该为:---------------------------------------------------------- 参赛号 姓 名 最高分 最低分 累积分 最后得分 ---------------------------------------------------------- 1 zhangjin 9.7 7.9 44.9 8.98 2 lintao 9.3 8.2 43.9 8.78 3 guojian 8.9 8.4 42.9 8.58 4 maling 8.9 7.9 4

思考:可进一步考虑找出比赛的第1至第k名,也在屏幕以及f2.txt中同时输出相关的结果信息(k小于等于n,并规定若多个选手最后得分相同时,则有效分(即已删除原来的最高分后)中最高分高者名次优先),(二) 设计根据题目,建立结构体player,其成员如下:类型成员名描述intnumber选手序号charname选手名字double *score选手得分然后建立函数,如下表:类型函数名描述doublemax_score求最大分数doublemin_score求最小分数doublemax_score2求第二大分数doublemin_score2求第二小分数doubleget_totalscore求选手总分doubleget_tscore求选手累计得分doubleget_lastscore求选手最后得分(三) 用户手册用户只需将f1.txt放入文件夹中,运行程序,然后会在屏幕输出文件f1.txt和文件f2.txt中的内容,文件f2.txt保存在文件夹中,(四) 调试及测试打开文件程序,运行计算各位选手的得分情况,(1)运行实例:(2)进一步改进:无论评委几人,程序都会找出第二高分和第二低分,可以改为只有在评委人数大于9人时执行,(3)附录源程序#include #include using namespace std; Struct player/player/structure body {int number; Char name [40]. Double * score;//member list}; Double min_score (double s [], int n);//for the lowest score double max_score (double s [], int n);//for the highest score double get_totalscore (double s [], int n);//o score double min_score2 (double s [], int n);//for the second lowest score double max_score2 (double s [], int n);//

The original topic and the analysis of the following baidu article database:

Report [programming to deal with the results score - baidu library] https://wk.baidu.com/view/fc1f36c0aa00b52acfc7cadd? FromShare=1 & amp; Fr=copy& Copyfr=copylinkpop
  • Related