diff options
Diffstat (limited to 'wk3/pset')
-rw-r--r-- | wk3/pset/runoff/runoff.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index 9ff4d19..17b4bf2 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -187,7 +187,8 @@ int find_min(void) // look through all candidates for (int i = 0; i < candidate_count; i++) { - if (!candidates[i].eliminated) { + if (!candidates[i].eliminated) + { // if the new candidate has less votes than previous if (candidates[i].votes < candidates[dead[0]].votes) { @@ -207,13 +208,29 @@ int find_min(void) // Return true if the election is tied between all candidates, false otherwise bool is_tie(int min) { - // TODO - return false; + for (int i = 0; i < candidate_count; i++) + { + if (!candidates[i].eliminated) + { + if (candidates[i].votes != min) { + return false; + } + } + } + return true; } // Eliminate the candidate (or candidates) in last place void eliminate(int min) { - // TODO + for (int i = 0; i < candidate_count; i++) + { + if (!candidates[i].eliminated) + { + if (candidates[i].votes == min) { + candidates[i].eliminated = true; + } + } + } return; } |