summaryrefslogtreecommitdiff
path: root/wk3/pset
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 05:05:06 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 05:05:06 +0000
commitb4e514a2f874870027adde49f7ebbf2b972ebce1 (patch)
treec118105eb7da68f4042c87b7aedb13c8e49db4ba /wk3/pset
parentffb5fe7131638a328ed10a9853af2bada154a20d (diff)
Sun, Feb 18, 2024, 9:05 PM -08:00
Diffstat (limited to 'wk3/pset')
-rw-r--r--wk3/pset/plurality/plurality.c9
1 files changed, 4 insertions, 5 deletions
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;
}