From b4e514a2f874870027adde49f7ebbf2b972ebce1 Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 05:05:06 +0000 Subject: Sun, Feb 18, 2024, 9:05 PM -08:00 --- wk3/pset/plurality/plurality.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'wk3/pset') diff --git a/wk3/pset/plurality/plurality.c b/wk3/pset/plurality/plurality.c index 5df35c5..7ca92b4 100644 --- a/wk3/pset/plurality/plurality.c +++ b/wk3/pset/plurality/plurality.c @@ -88,7 +88,7 @@ void print_winner(void) // clear the list of winners for (int j = 1; j < candidate_count; j++) { - winners[j] = 0; + winners[j] = -1; } // put it at the start of the new list winners[0] = i; @@ -97,7 +97,7 @@ void print_winner(void) { for (int j = 1; j < candidate_count; j++) { - if (winners[j] == 0) + if (winners[j] == -1) { winners[j] = candidates[i].votes; } @@ -106,11 +106,10 @@ void print_winner(void) } for (int i = 0; i < candidate_count; i++) { - if (winners[i] != 0) + if (winners[i] != -1) { - + printf("Winners are %s", candidates[winners[i]].name); } - printf("Winners are %s", candidates[winners[i]].name); } return; } -- cgit v1.2.3