0

[Hi, i would like to set preference table but not able to set particular candidates evry time i am trying to change and set this i am getting different error. Any thought on this.[1]

Hi, i would like to set preference table but not able to set particular candidates evry time i am trying to change and set this i am getting different error. Any thought on this.

1

candidates[i].votes is a case for the tabulate function, and should not be considered in vote, which is only meant to record a given vote.

To determine the candidate with the name match, you would check strcmp(candidates[j].name, name), since your loop uses j variable to iterate over the array.

And inside this if, you would have to set the correct value in preferences. preferences has two indices. The first one is the number of the voter, the second is the rank of that vote. The value assigned should be the index of the candidate with the name match.

9
  • Thanks @Blauelf, to implement preferences, there should be two for loops, one for number of voters(voter_count) and other for rank (iterating th' candidate_count) and this should be equal to candidate_count ? because in discord someone was discussing vote function has only voter, so no need to iterate over all voter. My code is here pastebin.com/0aPw99BN Jan 12 '20 at 3:21
  • Why do you still have two variables i and j in vote? There should be one.
    – Blauelf
    Jan 12 '20 at 8:39
  • preferences[voter][rank] = candidates[i].name[i]; Jan 12 '20 at 8:40
  • pastebin.com/t2nYq9F1 here is my complete code Jan 12 '20 at 8:42
  • Assign the index, preferences[voter][rank] = i;
    – Blauelf
    Jan 12 '20 at 8:42

You must log in to answer this question.

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