From 115b88e4fd7e06afe5a969a9f2210f5629787f51 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 21:41:27 +0000 Subject: Mon, Feb 19, 2024, 1:41 PM -08:00 --- wk3/pset/runoff/runoff.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'wk3/pset/runoff/runoff.c') diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index b727f59..e843f32 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -164,15 +164,23 @@ void tabulate(void) // Print the winner of the election, if there is one bool print_winner(void) { + int f = 0; for (int i = 0; i < candidate_count; i++) { if (candidates[i].votes >= (voter_count / 2)) { printf("%s", candidate.name); - return true; + f++; } } - return false; + if (f > 0) + { + return true; + } + else + { + return false; + } } // Return the minimum number of votes any remaining candidate has -- cgit v1.2.3