From 17df1b297e72d3677094ad4862cb33f017112eff Mon Sep 17 00:00:00 2001 From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> Date: Mon, 19 Feb 2024 20:18:15 +0000 Subject: Mon, Feb 19, 2024, 12:18 PM -08:00 --- wk3/pset/runoff/runoff.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'wk3/pset/runoff/runoff.c') diff --git a/wk3/pset/runoff/runoff.c b/wk3/pset/runoff/runoff.c index 3d3152e..f8a17fd 100644 --- a/wk3/pset/runoff/runoff.c +++ b/wk3/pset/runoff/runoff.c @@ -127,7 +127,14 @@ int main(int argc, string argv[]) // Record preference if vote is valid bool vote(int voter, int rank, string name) { - // TODO + for (int i = 0; i < candidate_count; i++) + { + if (!strcmp(name, candidates[i].name)) + { + preferences[voter][rank] = candidates[i].name; + return true; + } + } return false; } -- cgit v1.2.3