Пример #1
0
function recur($a)
{
    if ($a['next'] == "video" || $a['next'] == "") {
        return;
    }
    echo "<table><tr><td>";
    echo "<ul>";
    $abc = $a['infolder'] . $a['next'];
    $subrow = mysql_query("SELECT * FROM data WHERE infolder='{$abc}'") or die("unablle" . mysql_error());
    while ($subtab = mysql_fetch_array($subrow)) {
        echo "<li>";
        $len = strlen($subtab['data']);
        $title = substr($subtab['data'], 0, $len - 5);
        if ($subtab['next'] == "video") {
            $next = "video.php?ved=" . $subtab['infolder'] . $title . ".ogv";
            echo "<a href='{$next}'>";
        } else {
            $next = "spivision.php?next=" . $subtab['infolder'] . $subtab['next'];
            echo "<a href='{$next}'>";
        }
        echo "{$title}";
        echo "</a>";
        recur($subtab);
        echo "</li>";
    }
    echo "</ul>";
    echo "</td></tr></table>";
}
Пример #2
0
function recur($i, $j)
{
    if ($i > $j) {
        return;
    }
    if ($i % 2) {
        echo $i . ", ";
    }
    $i++;
    recur($i, $j);
}
Пример #3
0
function display($select = 0)
{
    $a = 0;
    $rs = recur($a);
    $str = '<select>';
    foreach ($rs as $k => $v) {
        if ($v['id'] == $select) {
            $str .= '<option selected="selected">';
            $str .= $v['cname'];
            $str .= '</option>';
        } else {
            $str .= '<option>';
            $str .= $v['cname'];
            $str .= '</option>';
        }
    }
    $str .= '</select>';
    return $str;
}
Пример #4
0
function dist($r, $p)
{
    global $maxt, $mint, $K, $nattr, $cattr, $height;
    $Dist = array();
    for ($i = 0; $i < count($p); $i++) {
        $first = 0;
        $second = 0;
        mysql_query("CREATE TABLE `dist` (\n\t  `id` int(4) NOT NULL AUTO_INCREMENT,\n\t  `Education` varchar(20) NOT NULL,\n\t  `Sex` varchar(1) NOT NULL,\n\t  `Work` int(3) NOT NULL,\n\t  `Disease` varchar(20) NOT NULL,\n\t  `Salary` int(6) NOT NULL,\n\t  PRIMARY KEY (`id`)\n\t\t)");
        mysql_query("insert into dist select * from clus" . $p[$i]);
        mysql_query("insert into dist values(" . $r['sl'] . "," . $r['Education'] . "," . $r['Sex'] . "," . $r['Work'] . "," . $r['Disease'] . "," . $r['Salary'] . ")");
        foreach ($nattr as $na) {
            $max = mysql_query("select max(" . $na . ") from dist");
            $nmax = mysql_fetch_array($max);
            $min = mysql_query("select min(" . $na . ") from dist");
            $nmin = mysql_fetch_array($min);
            $first = $first + ($nmax[0] - $nmin[0]) / ($maxt[$na] - $mint[$na]);
        }
        mysql_query("delete * from dist");
        mysql_query("drop table dist");
        foreach ($cattr as $c => $ca) {
            $new = array();
            $ar = array();
            $sP = mysql_query("select distinct(" . $c . ") from clus" . $p[$i]);
            while ($SP = mysql_fetch_array($sP)) {
                $ar[] = $SP;
            }
            if (count($new) == 1 && strcmp($new[0], $x[$c]) == 0) {
                $second = 0;
            } else {
                foreach ($ar as $x) {
                    array_push($new, $x[$c]);
                }
                //r is an array
                $ances = recur($new, array_search($r[$c], $ca), $ca);
                //find height till parent node = root
                $subheight = calcHeight(array_search($r[$c], $ca), $ances);
                $second = $second + $subheight / $height[$c];
            }
        }
        $Dist[$p[$i]] = $first + $second;
    }
    return $Dist;
}
Пример #5
0
/**
 * Solve using recursivity. Slow in PHP.
 */
function problem024($index, $digits)
{
    $answer = array();
    recur($index - 1, str_split($digits), &$answer);
    return $answer[0];
}