summaryrefslogtreecommitdiff
path: root/wk3/pset/runoff
diff options
context:
space:
mode:
authorFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 20:18:15 +0000
committerFudgerboy <91767657+Fudgerboy@users.noreply.github.com>2024-02-19 20:18:15 +0000
commit17df1b297e72d3677094ad4862cb33f017112eff (patch)
tree3d434211802bb2387e41049e1b4c5457e5466be1 /wk3/pset/runoff
parenta8eed6f474479979a190be92257f06252c39d590 (diff)
Mon, Feb 19, 2024, 12:18 PM -08:00
Diffstat (limited to 'wk3/pset/runoff')
-rw-r--r--wk3/pset/runoff/runoff.c9
1 files changed, 8 insertions, 1 deletions
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;
}