diff options
Diffstat (limited to 'wk3')
-rw-r--r-- | wk3/pset/runoff/runoff.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index b218642..9f08058 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -164,18 +164,6 @@ void tabulate(void) // Print the winner of the election, if there is one bool print_winner(void) { - /* - go through each candidate - if they have more than 50% of the votes they win - print winner - return true; - else - filter through all candidates - see who has the least votes and eliminate them - return false; - */ - - /* int dead[candidate_count]; dead[0] = 0; // set the unused spaces of the array of least voted @@ -190,21 +178,17 @@ bool print_winner(void) printf("%s", candidate.name); return true; } - else if () + else if (candidates[dead[0]].votes > candidates[i].votes) // if the new candidate has more less than previous { - if (candidates[winners[0]].votes < candidates[i].votes) // if the new candidate has more votes than previous + // clear the list of dead + for (int j = 1; j < candidate_count; j++) { - // clear the list of winners - for (int j = 1; j < candidate_count; j++) - { - winners[j] = -1; - } - // put it at the start of the new list - winners[0] = i; + dead[j] = -1; } + // put it at the start of the new list + dead[0] = i; } } - */ return false; } |