From ddad787a896a254e3ba68fd9f51c2586138f8aa8 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 02:48:32 +0000 Subject: Sun, Feb 18, 2024, 6:48 PM -08:00 --- wk3/pset/plurality/plurality.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wk3/pset') diff --git a/wk3/pset/plurality/plurality.c b/wk3/pset/plurality/plurality.c index 1284cfa..575434a 100644 --- a/wk3/pset/plurality/plurality.c +++ b/wk3/pset/plurality/plurality.c @@ -83,13 +83,14 @@ void print_winner(void) winners[0] = candidates[0].name; for (int i = 1; i < candidate_count - 1; i++) { - if (winners[0] < candidates[i].name) + if (winners[0] < candidates[i].name) //if the new candidate has more votes than all previous { - + //clear the list of winners for (int j = 1; j < candidate_count - 1; j++) { winners[j] = 0; } + //put it at the start of the new list winners[0] = candidates[i].name; } } -- cgit v1.2.3