diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-19 21:33:03 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-19 21:33:03 +0000 |
commit | 8162924303d9ecc554da52782e70f0425d51d2a7 (patch) | |
tree | 6209c0900d98ff2d29ba31fbf43e163050dc6fbd /wk3/pset/runoff | |
parent | 6595d5c455765832d2f77d64472add335a52f252 (diff) |
Mon, Feb 19, 2024, 1:33 PM -08:00
Diffstat (limited to 'wk3/pset/runoff')
-rw-r--r-- | wk3/pset/runoff/runoff.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index f3e31b2..b218642 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -176,16 +176,32 @@ bool print_winner(void) */ /* - for (int i = 0; i < candidate_count; ) + int dead[candidate_count]; + dead[0] = 0; + // set the unused spaces of the array of least voted + for (int j = 1; j < candidate_count; j++) { - if (candidates.votes >= (voter_count / 2)) + dead[j] = -1; + } + for (int i = 0; i < candidate_count; i++) + { + if (candidates[i].votes >= (voter_count / 2)) { printf("%s", candidate.name); return true; } else if () { - + if (candidates[winners[0]].votes < candidates[i].votes) // if the new candidate has more votes than previous + { + // 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; + } } } */ |