0

I have been looking up and down through my code to no avail. Check50 shows that all tests are successful except for "is_tie detects tie after some candidates have been eliminated". I haven't the foggiest why this would be...

Please find my code presented below. Any guidance is greatly appreciated!

bool is_tie(int min)
{
    bool mass_tie;

    for (int i = 0; i < candidate_count; i++)
    {
        if (candidates[i].eliminated == false && candidates[i].votes == min)
        {
            mass_tie = true;
        }
        else
        {
            mass_tie = false;
        }
    }
    return mass_tie;
}
0

It's bad design by them. To accomplish things in Runoff usually you need candidate[i].eliminated == false but in this particular for loop you need it to be true so that && is evaluated to true.

BUT candidate[i].eliminated is evaluated to false right now so you automatically are removed from mass_tie = true; and put to mass_tie = false;

Try to nest two if statements with each condition.

A better naming would've been candidate[i].ongoing or candidate[i].present Gave me head aches too. Hope this helps at least others if you are past this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .