Connor: Algorithmus gesucht KO-System

Beitrag lesen

Soweit bin ich schon mal.
Was mich noch stört, ist das ich in der FOR-Schleife die $anzahl immer wieder addieren muss.
Ob das elleganter geht ? * :-)

  
/* Max Anzahl: 8, 16, 32, 64 */  
$maxanzahl = 64;  
$spieler = range(1, $maxanzahl);  
/* Spiel um Platz 3 ? Coding fehlt noch */  
$platz_3 = false;  
/*  
foreach ($spieler as $werte)  
{  
print "<pre>";  
print_r ($werte);  
print "</pre>";  
}  
Folgt noch */  
  
$anzahl = count($spieler);  
  
$out = "Gesamt Spieler: $anzahl<br>";  
$out .= "<br>";  
$out .=  "Runde 1: ".($anzahl/2)." Spiele<br>";  
for($count = 1; $count <= $anzahl/2; $count++)  
{  
 $out .= "Spiel ".$count."<br>";  
}  
  
$out .= "<br>";  
  
$out .=   "Runde 2: ".($anzahl/4)." Spiele<br>";  
for($count = $count; $count <= ($anzahl/2)+($anzahl/4); $count++)  
{  
$out .= "Spiel ".($count)."<br>";  
}  
  
$out .= "<br>";  
  
$out .= "Runde 3: ".($anzahl/8)." Spiele<br>";  
for($count = $count; $count <= ($anzahl/8)+($anzahl/4)+($anzahl/2); $count++)  
{  
$out .= "Spiel ".($count)."<br>";  
}  
$out .= "<br>";  
  
if (!is_float($anzahl/16) ){  
$out .=   "Runde 4: ".($anzahl/16)." Spiele<br>";  
for($count = $count; $count <= ($anzahl/16)+($anzahl/8)+($anzahl/4)+($anzahl/2); $count++)  
{  
$out .= "Spiel ".($count)."<br>";  
}  
$out .= "<br>";  
}  
  
if (!is_float($anzahl/32)){  
$out .= "Runde 5: ".($anzahl/32)." Spiele<br>";  
for($count = $count; $count <= ($anzahl/32)+($anzahl/16)+($anzahl/8)+($anzahl/4)+($anzahl/2); $count++)  
{  
$out .= "Spiel ".($count)."<br>";  
}  
$out .= "<br>";  
}  
  
if (!is_float($anzahl/64)){  
$out .= "Runde 6: ".($anzahl/64)." Spiele<br>";  
for($count = $count; $count <= ($anzahl/64)+($anzahl/32)+($anzahl/16)+($anzahl/8)+($anzahl/4)+($anzahl/2); $count++)  
{  
$out .= "Spiel ".($count)."<br>";  
}  
  
}  
echo $out;  

Gruss Connor