var $a, $b, $c, $d, $m, $n; function dis1($feet, $inch) { $this->a = $feet; $this->b = $inch; } function dis2($feet, $inch) { $this->c = $feet; $this->d = $inch; } function showitem() { $this->m = $this->a + $this->c; $this->n = $this->d + $this->b; while ($this->n >= 12) { if ($this->n >= 12) { $this->m = $this->m + 1; $this->n = $this->n - 12; } } echo 'feet is = ' . $this->m . 'Inch is = ' . $this->n; } } $c1 = new dist(); $c1->dis1(12, 4); $c1->dis2(12, 8); $c1->showitem(); ?> </body> </html>
$strStdin = trim(fgets(STDIN)); list($x, $y, $dummy) = explode(",", $strStdin, 3); $arrDataset[] = array("x" => floatval($x), "y" => floatval($y)); } // get the number of datasets $maxN = $arrDataset[0]["x"]; // remove the first element from the array array_splice($arrDataset, 0, 1); // remove the last element from the array array_pop($arrDataset); reset($arrDataset); if (0 < $maxN) { for ($i = 0; $i <= $maxN - 2; $i++) { $wkAns = 1; for ($j = $i + 1; $j <= $maxN - 1; $j++) { $dist = new dist(); $dist->setCenterPointA($arrDataset[$i]["x"], $arrDataset[$i]["y"]); $dist->setCenterPointB($arrDataset[$j]["x"], $arrDataset[$j]["y"]); if (NUM_DIST >= $dist->getDist()) { $wkAns++; } } if ($wkAns > $ans) { $ans = $wkAns; } } } else { $ans = 0; } // output answer to stdout fwrite(STDOUT, "Ans:" . $ans . PHP_EOL);