• This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #1197
    admin
    Keymaster
      // 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]

    Viewing 1 post (of 1 total)
    • You must be logged in to reply to this topic.
    Scroll to Top