Advertisement
decs4usa

plurality functions

Jan 23rd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. // Update vote totals given a new vote
  2. bool vote(string name)
  3. {
  4.     for (int i = 0; i > MAX; i++)
  5.     {
  6.         if (strcmp(candidates[i].name == 0))
  7.  
  8.         return 1 + candidates[i].votes;
  9.         return true;
  10.  
  11.         else
  12.  
  13.         return false;
  14.     }
  15. }
  16.  
  17. // Print the winner (or winners) of the election
  18. void print_winner(void)
  19. {
  20.     int voter_count(int candidates[i].votes)
  21.     {
  22.         int i, voter_count = 0;
  23.         for (i = 0; i < n; i ++)
  24.         {
  25.             if candidates[i].votes >= voter_count)
  26.             voter_count = candidates[i].votes;
  27.             candidates[i].votes = candidates[i].names;
  28.         }
  29.         printf("%s\n", candidates[i].names);
  30.         return 0;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement