(I can't get formatting to work properly here so it might look a bit weird)
void tabulate(void) {
int j = 0;
for(int i = 0; i < candidate_count; i++)
{
for( ; j < voter_count;)
{
//check candidate in position [i][j] in preferences table, if not eliminated then update vote total and move to next row
if(candidates[preferences[i][j]].eliminated == false)
{
candidates[preferences[i][j]].votes++;
j++;
}
//if candidate is eliminated move down one row and do not update vote total
if(candidates[preferences[i][j]].eliminated == true)
{
j++;
}
}
//reset j to zero to start from top of table again
j = 0;
}
return;
}
To me, this makes sense, but it fails every test through check50 and gives candidates seemingly random vote values. If anyone can help me with this it would be very much appreciated, thanks.
(also all other parts of my code pass so I don't think it's a returning error from those)