test asort
This commit is contained in:
67
methods/schulzeResults.php
Normal file
67
methods/schulzeResults.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
class schulze
|
||||
{
|
||||
public int $nvotant;
|
||||
public int $ncandidats;
|
||||
public array $nvotes;
|
||||
|
||||
$v = array(
|
||||
array(5, 1, 3, 2, 4),
|
||||
array(1, 5, 2, 4, 3),
|
||||
array(5, 3, 2, 4, 1),
|
||||
array(5, 1, 3, 2, 4)
|
||||
);
|
||||
|
||||
function matrix()
|
||||
{
|
||||
foreach($nvotes as $votes)
|
||||
{
|
||||
for ($i=1;$i<=$votes;$i++)
|
||||
{
|
||||
for ($j=1;$j<=$ncandidats;$j++)
|
||||
{
|
||||
void
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function test($v)
|
||||
{
|
||||
asort($v);
|
||||
var_dump($v);
|
||||
}
|
||||
|
||||
function result()
|
||||
{
|
||||
for ($i=1;$i<=$ncandidats;$i++)
|
||||
{
|
||||
for ($j=1;$j<=$ncandidats;$j++)
|
||||
{
|
||||
if ($d[$i][$j] > $d[$j][$i])
|
||||
{
|
||||
$p[$i][$j] = $d[$i][$j];
|
||||
}else
|
||||
{
|
||||
$p[$i][$j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($i=1;$i<=$ncandidats;$i++)
|
||||
{
|
||||
for ($j=1;$j<=$ncandidats;$j++)
|
||||
{
|
||||
for ($k=1;$k<=$ncandidats;$k++)
|
||||
{
|
||||
if ($j != $k)
|
||||
{
|
||||
$p[$j][$k] = max($p[$j][$k], min($p[$j][$i],$p[$i][$k]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user