void tabulate(void)
{
for (int i = 0; i < voter_count; i++) //as long as the number of total voters has not been met; this increases which voter we are on
{
int j = 0;
int plus1 = preferences[i][j]; //the integer plus1 is equal to the numerical equivalent of the candidate in voter's rank'th place
if (candidates[plus1].eliminated == false) //if the candidate plus1 has not been eliminated
{
candidates[plus1].votes++; //candidate plus1 gets a vote; need to exit out of this loop so i can increase
}
else //in this situation, where the top candidate has been eliminated, we must change the rank
{
int end = 0;
for (j = 1; end != 1; j++) //as long as j is less than the number of total candidates availble for voting
{
plus1 = preferences[i][j];
if (candidates[plus1].eliminated == false) //if this candidate is valid
{
candidates[plus1].votes++; //then we can add to this voter
end++; //quits this loop
}
//in this situation, where the top candidate has been eliminated, the rank will again increase
}
}
}
//once the previous voter is done, i aka voter increases so the next vote can be tabulated
return;
}
Hello, I've been getting this error on my code. :( tabulate counts votes when multiple candidates are eliminated tabulate function did not produce correct vote totals
I've run debug 50 on it on a situation where there were two eliminations (4 candidates, 6 voters), and it seemed to work okay. Am I misinterpreting the mistake?