Open erikccoder opened 3 years ago
function tabulate(){
global $preferences;
global $candidates;
global $numOfVoters;
global $numOfCandidate;
// Init
for($j=0; $j<$numOfCandidate; $j++)
{
$candidates[$cand]["votes"] = 0;
}
for ($i=0; $i<$numOfVoters; $i++)
{
$pref = $preferences[$i];
for($j=0; $j<$numOfCandidate; $j++)
{
$cand = $pref[$j];
if($candidates[$cand]["eliminated"] == false)
{
$candidates[$cand]["votes"]++;
break;
}
}
}
}
function tabulate(){
global $pref, $cand;
for ($i=0, $ccand=count($cand); $i<ccand; $i++){
$cand[$i][1] = 0;
}
for ($i=0, $cpref=count($pref); $i<cpref; $i++){
for ($j=0; $j<count($cand); $j++){
$votefor = $pref[$i][$j];
if (!$cand[$votefor][2]) {
$cand[$votefor][1]++;
break;
}
}
}
}
function tabulate($voter_count, $candidate_count)
{
global $preferences,$candidates;
for ($i = 0; $i < $voter_count; $i++)
{
for ($j = 0; $j < $candidate_count; $j++)
{
if($preferences[$i][1] == $candidates[$j]["name"])
{
$candidates[$j]["int"]++;
}
}
}
}