diff options
Diffstat (limited to 'wk3')
-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; + } } } */ |