summaryrefslogtreecommitdiff
path: root/wk3/pset/runoff
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 21:36:27 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 21:36:27 +0000
commit940e8355fadc164d3895a17cd91487878ff4000d (patch)
tree931a8ece06d23b56698c999eafeaca1c15c8473c /wk3/pset/runoff
parent8162924303d9ecc554da52782e70f0425d51d2a7 (diff)
Mon, Feb 19, 2024, 1:36 PM -08:00
Diffstat (limited to 'wk3/pset/runoff')
-rw-r--r--wk3/pset/runoff/runoff.c28
1 files changed, 6 insertions, 22 deletions
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;
}