1
0
This commit is contained in:
Daniel Tartavel 2022-09-23 16:06:03 +02:00
parent c5e0494dd7
commit 5c84c7eda6
2 changed files with 14 additions and 8 deletions

View File

@ -6,7 +6,7 @@ class schulze
public int $ncandidats; public int $ncandidats;
public array $nvotes; public array $nvotes;
public $v = array( public array $v = array(
array(5, 1, 3, 2, 4), array(5, 1, 3, 2, 4),
array(1, 5, 2, 4, 3), array(1, 5, 2, 4, 3),
array(5, 3, 2, 4, 1), array(5, 3, 2, 4, 1),
@ -22,7 +22,7 @@ class schulze
{ {
for ($j=1;$j<=$ncandidats;$j++) for ($j=1;$j<=$ncandidats;$j++)
{ {
void void;
} }
} }
} }
@ -31,25 +31,31 @@ class schulze
function test($v) function test($v)
{ {
$w = array(); $w = array();
$i = 0;
$j = 0;
asort($v); asort($v);
print_r($v); print_r($v);
for($i=0;isset($v);$v++) for($i = 0;$i < count($v) - 1;$i++)
{ {
if ($i == 0) if ($i == 0)
{ {
$w[] = $v[$i];
$w[$j]['vote'] = $v[$i];
$w[$j]['n'] = 1;
$j += 1;
} }
if ($v[$i] == $v[$i+1]) if ($v[$i] == $v[$i+1])
{ {
$w[$i] += 1; $w[$J]["n"] += 1;
}else }else
{ {
$w[] = $v[$i+1]; $w[$j++] = $v[$i+1];
}
} }
print_r($w); print_r($w);
} }
}
function result() function result()
{ {

View File

@ -2,7 +2,7 @@
require "methods/schulzeResults.php"; require "methods/schulzeResults.php";
$vote = new schulze; $vote = new schulze;
$vote->test(); $vote->test($vote->v);
?> ?>