2009-03-21 8 views
-4

Wie bekomme ich diesen PHP-Code, um HTML auszugeben, um die Spielernummer einzugeben und das Turnier zu generieren?Wie bekomme ich diesen PHP-Code zur Ausgabe von HTML?

<?php 
class RoundRobin 
{ 
var $MaxTeams; 
var $MaxCombinations; 
var $tourn; 
var $mList; 
var $cList; 
var $cUsed; 
function RoundRobin($max) 
{ 
    $this->MaxTeams=$max; 
    $this->MaxCombinations=($this->MaxTeams/2)*($this->MaxTeams-1); 
} 
function ShowSchedule($players,$totalChecks) 
{ 
    echo $players.' players'."\n"; 
    for ($r=1; $r <= $players/2; $r++) echo 'Game'.$r; 
    echo "\n"; 
    echo"  +-"; 
    for ($r=1; $r <= ($players/2)*6-2; $r++) echo '-'; 
    echo "\n"; 
    $index = 1; 
    for ($r=1; $r <= $players-1; $r++) 
    { 
    echo 'Week '.$r. '|'; 
    for ($m=1; $m <= $players/2; $m++) 
    { 
     echo $this->tourn[$index]['one'].'&amp;'. $this->tourn[$index]['two']; 
     $index++; 
    } 
    echo "\n"; 
    } 
    echo "\n".$totalChecks,' combinations tried'. "\n\n"; 
} 
function array_copy(&$dest,$source) 
{ 
    if(count($source)>count($dest)) {echo 'fatal'; exit;} 
    //for($a=0;$a<count($source);$a++) 
    $dest['one']=$source['one']; 
    $dest['two']=$source['two']; 
} 
function ClearArrays() 
{ 
    for ($i=0; $i <= $this->MaxCombinations; $i++) 
    { 
    $this->tourn[$i]['one']=0; 
    $this->tourn[$i]['two']=0; 
    $this->cList[$i]['one']=0; 
    $this->cList[$i]['two']=0; 
    $this->cUsed[$i]=0; 
    if($i<=$this->MaxTeams/2)$this->mList[$i] = 0; 
    } 
} 
function Scheldule($players) 
{ 
    while ($players <= $this->MaxTeams) 
    { 
$combinations = $players/2 * ($players-1); 
    $totalChecks = 0; 
$this->ClearArrays(); 
    /* set up list of all combinations */ 
    $m=1; 
    for ($a=1; $a<$players; $a++) 
     for ($b=$a+1; $b<=$players; $b++) 
     { 
     $this->cList[$m]['one'] = $a; 
     $this->cList[$m]['two'] = $b; 
     $m++; 
     } 
    $roundCount=1; 
    $index=1; 
    while ($roundCount <= $players-1) 
    { 
     $matchCount = 1; 
     $round_set = 0; 
     for ($i=0; $i<=$this->MaxTeams/2; $i++) $this->mList[$i] = 0; 
     $startC = $roundCount; 
     while ($matchCount <= $players/2) 
     { 
      $c = $combinations + 1; 
      while ($c > $combinations) 
      { 
       $c = $startC; 
       /* find an unused pair that would be legitimate */ 
       while (
       ($c <= $combinations) 
       && 
         (// 
         ($round_set & (1 << $this->cList[$c]['one'])) || 
         ($round_set & (1 << $this->cList[$c]['two'])) || 
         (!empty($this->cUsed[$c])) 
        ) 
        ) $c++; 
       if ($c > $combinations) 
       { 
        do { 
        $this->mList[$matchCount] = 0; 
        $matchCount--; 
        $index--; 
        $round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['one']); 
        $round_set &= ~(1 << $this->cList[$this->mList[$matchCount]]['two']); 
        $this->cUsed[$this->mList[$matchCount]] = false; 
        $this->tourn[$index]['one'] = 0; 
        $this->tourn[$index]['two'] = 0; 
        } 
        while ($this->cList[$this->mList[$matchCount]]['one'] != $this->cList[$this->mList[$matchCount]+1]['one']); 
        $startC = $this->mList[$matchCount]+1; 
       } 
      } 
      $this->array_copy(&$this->tourn[$index],$this->cList[$c]); 
      $totalChecks++; 
      if (($totalChecks % 1000) == 0) printf("%d\033A\n", $totalChecks); 
      $this->cUsed[$c] = true; 
      $this->mList[$matchCount] = $c; 
      $startC = 1; 
      $round_set |= (1 << $this->cList[$c]['one']); 
      $round_set |= (1 << $this->cList[$c]['two']); 
      $index++; 
      $matchCount++; 
     } 
     $roundCount++; 
    } 
    /* yahoo!, scheduled all the rounds */ 
    printf("   "); 
    $this->ShowSchedule($players,$totalChecks); 
    /* try and make a schedule using two more teams */ 
    $players += 2; 
    } 
    } 
} 
?> 
+0

Also ... was ist die Frage? Wie schreibe ich HTML, um dieses Skript zu posten? Ich meine, Sie wissen, wie man dieses intrinsische Skript programmiert, wissen aber nicht, wie man ein einfaches HTML-Formular schreibt? – Seb

+0

Erarbeiten Sie mehr die Frage und schneiden Sie den Code, den Sie einfügen – vartec

+0

Ich habe es nicht geschrieben, ich habe es von meinem Freund und ich möchte versuchen, es auszuführen, aber es hat nicht funktioniert. Deshalb frage ich. – Siva

Antwort

2

Es ist eine PHP-Klasse. Reading the manual könnte Ihnen helfen.

Etwas nach dem Vorbild dieser Macht Arbeit:

$rr = new RoundRobin(5); 

$rr->Scheldule($_POST['PlayerCount']); 

Aber ich kann nicht entziffern den Code gestört werden, um herauszufinden, ob es wirklich will.

Wenn Sie noch nicht HTML-Formulare gelernt haben, lesen Sie ein Tutorial wie w3schools.

+0

Lol ... Ich weiß, wie man html tut ... aber es hat nicht funktioniert..das y fragte ich – Siva

Verwandte Themen