decs4usa

plurality functions

Jan 22nd, 2020
62
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Update vote totals given a new vote
  2. bool vote(string name)
  3. {
  4.     candidate[0].name = “Erin”;
  5.     candidate[1].name = “Dax”;
  6.     candidate[2].name = “Christian”;
  7.     candidate[3].name = “Skylar”;
  8.  
  9.     for (int i = 0; i < 4, i ++)
  10.     {
  11.         if (strcmp (candidate[i].name, “Erin”, “Dax”, “Christian”, “Skylar”) == 0)
  12.  
  13.             return 1 + candidates[i].votes
  14.             return true;
  15.  
  16.         else
  17.  
  18.             return false;
  19.     }
  20. }
  21.  
  22. // Print the winner (or winners) of the election
  23. void print_winner(void)
  24. {
  25.     if (candidates[i].votes >= candidates[i++].votes)
  26.     return candidates[i].name;
  27. }
RAW Paste Data