summaryrefslogtreecommitdiff
path: root/wk3/pset
diff options
context:
space:
mode:
Diffstat (limited to 'wk3/pset')
-rw-r--r--wk3/pset/plurality/plurality.c5
1 files changed, 3 insertions, 2 deletions
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;
}
}