From 940e8355fadc164d3895a17cd91487878ff4000d Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:36:27 +0000 Subject: Mon, Feb 19, 2024, 1:36 PM -08:00 --- wk3/pset/runoff/runoff.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'wk3/pset') diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index b218642..9f08058 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -164,18 +164,6 @@ void tabulate(void) // Print the winner of the election, if there is one bool print_winner(void) { - /* - go through each candidate - if they have more than 50% of the votes they win - print winner - return true; - else - filter through all candidates - see who has the least votes and eliminate them - return false; - */ - - /* int dead[candidate_count]; dead[0] = 0; // set the unused spaces of the array of least voted @@ -190,21 +178,17 @@ bool print_winner(void) printf("%s", candidate.name); return true; } - else if () + else if (candidates[dead[0]].votes > candidates[i].votes) // if the new candidate has more less than previous { - if (candidates[winners[0]].votes < candidates[i].votes) // if the new candidate has more votes than previous + // clear the list of dead + for (int j = 1; j < candidate_count; j++) { - // 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; + dead[j] = -1; } + // put it at the start of the new list + dead[0] = i; } } - */ return false; } -- cgit v1.2.3