// Update ranks given a new vote
bool vote(int rank, string name, int ranks[])
{
// TODO
for (int i = 0; i < candidate_count; i++)
{
if (strcmp(name, candidates) == 0)
{
//NEED TO INCREMENT VOTES RECEIVED BY CANDIDATES BY 1 FOR RANKS[J]
preferences[rank] = preferences[rank] + 1;
printf("rank is %i", preferences[rank]);
return true;
}
}
return false;
}
Not sure if I am moving in the right direction. By the above vote function, no. of votes for a particular rank getting incremented by 1. Is that the objective of the vote function?
Reply
CS50x – Ed Discussion (edstem.org)
[learn_press_profile]