篮球运动员得分计算器不起作用

时间:2019-04-06 20:51:00

标签: c++11

我正在制定一个程序,在此程序中,您输入n个球员,尝试三分,尝试三分,尝试两分,尝试两分,尝试罚球,进行罚球,然后检查是否没有射门次数多于尝试射门次数,程序必须找到最准确的球员总得分(最准确的是所有射门次数最多的球员)。

#include <iostream>
#include <vector>

using namespace std;

class Player {
private:
    long int thra, thrm, twa, twm, fta, ftm;
public:
    void Input() {
        long int thra1, thrm1, twa1, twm1, fta1, ftm1;
        cin >> thra1 >> thrm1 >> twa1 >> twm1 >> fta1 >> ftm1;
        if (thrm1 <= thra1 && twm1 <= twa1 && ftm1 <= fta1) {
            thra = thra1;
            thrm = thrm1;
            twa = twa1;
            twm = twm1;
            fta = fta1;
            ftm = ftm1;
        }
        else {
            returnFalse();
        }
    }

    bool returnFalse() {
        return false;
    }

    long int mostPoints() {
        double acc = 0, maxacc = 0;
        long int maxpts = 0;

        if ((thra + twa + fta) > 0) {
            acc = 100 * ((thrm + twm + ftm) / (thra + twa + fta));
        }
        else {
            acc = 0;
        }
        if (acc > maxacc) {
            maxacc = acc;
            maxpts = (thrm) * 3 + (twm) * 2 + ftm;
        }
        return maxpts;
    }
};

int main() {
    int n;
    cin >> n;

    vector<Player*> players;
    for (int i = 0; i < n; i++) {
        Player *newPlayer = new Player();
        newPlayer->Input();
        players.push_back(newPlayer);
    }
    long int points = 0;

    for (int i = 0; i < n; i++) {
        points = players[i]->mostPoints();
    }

    cout << points;
}

任何输入的答案都是0,我无法发现我的错误。有人可以帮忙吗?

0 个答案:

没有答案