From 8416c99e088f982f8591e56eb48709f55c7dc908 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:47:48 +0000 Subject: Mon, Feb 19, 2024, 1:47 PM -08:00 --- wk3/pset/runoff/runoff.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index c86de87..f7fbcfa 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -179,13 +179,16 @@ int find_min(void) { int dead[candidate_count]; dead[0] = 0; + // set unused places of the dead array for (int j = 1; j < candidate_count; j++) { dead[j] = -1; } + // look through all candidates for (int i = 0; i < candidate_count; i++) { - if (candidates[dead[0]].votes > candidates[i].votes) // if the new candidate has more less than previous + // 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++) @@ -196,7 +199,7 @@ int find_min(void) dead[0] = i; } } - return 0; + return candidates[dead[0]].votes; } // Return true if the election is tied between all candidates, false otherwise -- cgit v1.2.3