summaryrefslogtreecommitdiff
path: root/wk3/pset/runoff
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 21:49:10 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 21:49:10 +0000
commitf2e05d8531caf422d82c57eb512bd3b105c8fc49 (patch)
treea19bfe497204cfb60216e0c68044cfd799a4c3e1 /wk3/pset/runoff
parent8416c99e088f982f8591e56eb48709f55c7dc908 (diff)
Mon, Feb 19, 2024, 1:49 PM -08:00
Diffstat (limited to 'wk3/pset/runoff')
-rw-r--r--wk3/pset/runoff/runoff.c18
1 files changed, 10 insertions, 8 deletions
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;