diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-19 02:54:25 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-02-19 02:54:25 +0000 |
commit | 6660846df6d13da0e08966bc7c18c5c38e9ef99f (patch) | |
tree | b5b937a510784dd1635f1adfee6218783ba9d228 /wk3/pset/plurality | |
parent | 9f5587f069d0a40c35bf5652ee42b71168daf7ce (diff) |
Sun, Feb 18, 2024, 6:54 PM -08:00
Diffstat (limited to 'wk3/pset/plurality')
-rw-r--r-- | wk3/pset/plurality/plurality.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/wk3/pset/plurality/plurality.c b/wk3/pset/plurality/plurality.c index d39779f..cb8fee5 100644 --- a/wk3/pset/plurality/plurality.c +++ b/wk3/pset/plurality/plurality.c @@ -83,22 +83,23 @@ 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 the new candidate has more votes than all previous + if (winners[0] < candidates[i].name) // if the new candidate has more votes than all previous { - //clear the list of winners + // 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 + // put it at the start of the new list winners[0] = candidates[i].name; - } else if (winners[0] == candidates[i].name) + } + else if (winners[0] == candidates[i].name) { for (int j = 1; j < candidate_count - 1; j++) { if (winners[j] == 0) { - winners[j] == candidates[i].name; + winners[j] = candidates[i].name; } } } |