0
void print_winner(void)
{
    bool looser;
    for (int i = 0; i < pair_count; i++)
    {
        looser = false;
        for (int j = 0; j < pair_count; j++) //checks if each winner ever lost to any other one. If so, he won't be the source of the graph anymore.
        {
            if (pairs[j].winner == pairs[i].winner)
            {
                continue;
            }
            if (locked[pairs[j].winner][pairs[i].winner] == true)
            {
                looser = true;
                break;
            }
        }
        if (looser == false)
        {
            printf("%s\n", candidates[pairs[i].winner]);
            return;
        }
    }
    return;
}
0

for (int j = 0; j < candidate_count; j++)

In this line, you're only going up to the number of candidates, so you're not checking all the pairs.

| improve this answer | |
  • thats not the case actually. I was experimenting why that was not working and put candidate_count instead of pair_count. I didnt work either way. – Sajeeb Jul 7 at 22:41

You must log in to answer this question.

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