From f2e05d8531caf422d82c57eb512bd3b105c8fc49 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:49:10 +0000 Subject: Mon, Feb 19, 2024, 1:49 PM -08:00 --- wk3/pset/runoff/runoff.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'wk3/pset') diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index f7fbcfa..9ff4d19 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -187,16 +187,18 @@ int find_min(void) // look through all candidates for (int i = 0; i < candidate_count; i++) { - // if the new candidate has less votes than previous - if (candidates[i].votes < candidates[dead[0]].votes) - { - // clear the list of dead - for (int j = 1; j < candidate_count; j++) + if (!candidates[i].eliminated) { + // if the new candidate has less votes than previous + if (candidates[i].votes < candidates[dead[0]].votes) { - dead[j] = -1; + // clear the list of dead + for (int j = 1; j < candidate_count; j++) + { + dead[j] = -1; + } + // put it at the start of the new list + dead[0] = i; } - // put it at the start of the new list - dead[0] = i; } } return candidates[dead[0]].votes; -- cgit v1.2.3