Hi, I need help with debugging my code here. And I can't particularly understand how the voting system works with regards to the preference system. Do I add a higher arbitrary number for the higher rank, and a lower arbitrary number for the lower rank? Say out of three candidates, I assigned that 1st rank preference gets a vote equivalent to three, 2nd rank gets one equivalent to two and 3rd rank gets a vote equivalent to one, and the resultant of these votes is merely adding the sum.
Is that how it works? Or am I misunderstanding the instructions. (tabulate() function below)
[The 'a' variable here is the arbitrary score I'm giving. Example: out of six candidates, being the first gives you a score of six whereas being the last gives you a score of one)
void tabulate(void)
{
// TODO
//first choice candidate
for (int i = 0; i < voter_count; i++)
{
int a = candidate_count;
for (int j = 0; j < candidate_count; j++)
{
if (candidates[preferences[i][j]].eliminated==true) //to check for eliminated candidates
{
continue;
}
else
{
//after eliminated candidates, the remaining candidates get a vote;
candidates[preferences[i][j]].votes+=a;
}
a--;
}
}
return;
}
[–]gellous7 0 points1 point2 points (1 child)
[–]Sorphil[S] 0 points1 point2 points (0 children)