| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 366 人关注过本帖
标题:美式足球的解决方案探讨
只看楼主 加入收藏
SwanK
Rank: 1
等 级:新手上路
帖 子:68
专家分:3
注 册:2013-1-18
结帖率:50%
收藏
已结贴  问题点数:20 回复次数:1 
美式足球的解决方案探讨
英文的,不好意思啊!可是我很认真的。想了很久。一部分已经出来,但是
Background:
The passer rating (known as QB rating) is a formula for evaluating the performance of a quarterback in
football:
http://en.
From Wikipedia, here is the way to calculate it. First start by calculating a, b, c and d:

Where:
ATT = Number of passing attempts
COMP = Number of completions
YARDS = Passing yards
TD = Touchdown passes
INT = Interceptions
Then, the above calculations are used to complete the passer rating:
Technically, you have to make sure a,b,c and d stay in the range 0-2.375. If one is below/above that range,
you bring it back to either 0 or 2.375. I will not test with any values that require this step.
Problem:
Write a program that will read in a text file called QB.txt The file will consist of data in this order:
FirstName LastName Comp Att Yards TD Int
Something like:
Aaron Rodgers 343 502 4643 45 6
Calculate the QB Rating for the player and print the players “lastName, firstName” and then a space, then
the QB rating to one decimal. Something like:
Rodgers, Aaron 122.5
我的解决方案如下。请大家探讨。 感谢先!
*/

/**
 **********************************************************************************************************
 Program that will read in a text file called QB.txt The file will consist of data in this order:
 FirstName LastName Comp Att Yards TD Int
 Something like:
 Aaron Rodgers 343 502 4643 45 6
 Calculate the QB Rating for the player and print the players “lastName, firstName” and then a space, then
 the QB rating to one decimal. Something like:
 Rodgers, Aaron 122.5.
 **********************************************************************************************************
**/

   //Header file
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>

using namespace std;

int main()
{


   //Declare input file stream variable
  ifstream inData;
  ofstream outData;

   //Declare variables;
  int ATT, COMP,YARDS, TD, INT;

  double a,b,c,d;
  double QB_rating;

  string firstName;
  string lastName;


   inData.open("QB.txt");
   outData.open ("QB_Rating.txt");

   // get information from file input stream
   inData >> firstName >> lastName ;
   //getline (inData, firstName);
   inData >> COMP >> ATT >> YARDS >> TD >> INT ;
   setprecision(1);

   a = (float(COMP / ATT) - 0.3 ) * 5;
   b = (float(YARDS / ATT) -3 ) * 0.25;
   c = (float(TD / ATT ) )* 20 ;
   d = 2.375 -((float(INT / ATT) * 25 ));

    //if a <0
    //a=0;
    //if a > 2.375
    //a= 2.375;
    // same as b,c,d

cout <<a <<","<< b <<","<<c<<","<< d<< endl;
   QB_rating = ( a + b + c + d ) / 0.06 ;


   outData << fixed << showpoint ;
   outData << setprecision(1);

   outData << "QB Rating " << endl;

   inData >> firstName >> lastName ;
   outData << "lastName,firstName" <<setfill(' ') << "QB Rating" <<endl;
   outData << setw(8)<< lastName <<","<< firstName << " "<< right << QB_rating;
   //outData << "123456789012345678901234" << endl;

   inData.close();
   outData.close();

   return 0;
}



搜索更多相关主题的帖子: 解决方案 start rating passing 
2013-01-30 17:39
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:20 
可是我很认真的
------ 嘻嘻,真认真的人会译成中文
2013-01-31 08:14
快速回复:美式足球的解决方案探讨
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018126 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved