[![enter image description here][1]][1]
I keep getting a tabulation error with check50 that I cannot replicate
11 voters, 4 candidates, 3 or 4 rounds of voting works fine with I run it, and debug50 doesn't show anything either.
After a candidate is eliminated, I cycle voter preferences left (pref[j][0] = pref[j][0]) until there is a valid candidate in the [j][0] position, and then retabulate.
here is the change voter preference code and the tabulate code. i realise recursion be employed somewhere in this problem but I kept with loops.
int n = 0;
for (int i = 0; i < candidate_count; i++)
{
if (candidates[i].eliminated == true)
{
for (int j = 0; j < voter_count; j++)
{
if (preferences[j][0] == i)
{
do
{
for (int v = 0; v < candidate_count; v++)
{
preferences[j][v] = preferences[j][v + 1];
}
n = preferences[j][0];
}
while (candidates[n].eliminated == true);
}
}
}
}
// Reset vote counts back to zero
for (int i = 0; i < argc - 1; i++)
{
candidates[i].votes = 0;
}
}
```
```
void tabulate(void)
{
//iterate through the candidates
for (int i = 0; i < candidate_count; i++)
{
//identify remaining candidates
if (candidates[i].eliminated == false)
{for (int j = 0; j < voter_count; j++)
{
if (preferences[j][0] == i)
{
candidates[i].votes += 1;
}
}
}
}
return;
}```
[1]: https://i.stack.imgur.com/1qoF6.png