感谢 bird 告诉我 $_POST[] 的用法。代码如下:
<?php <BR> if ($_POST["perdata"] == "")<br> {<br> $_POST["perdata"] = "1 2 3 4";<br> }<br><br> $data = chop (trim ($_POST["perdata"]));<br> $a = explode (" ", $data);<br> sort ($a);<br> $data = implode (" ", $a);<br>?><br><br><?php <BR>function nextpermu (&$c)<br>{<br> $s = sizeof ($c);<br> $i = $s - 1;<br><br> while ($i > 0)<br> {<br> if ($c[$i] > $c[$i-1])<br> {<br> $j = $s-1;<br> while ($c[$j] $j--;<br> $t = $c[$i-1];<br> $c[$i-1] = $c[$j];<br> $c[$j] = $t;<br> //echo $i."-".$j."<br>";<br> for ($j=$s-1; $i {<br> $t = $c[$i];<br> $c[$i] = $c[$j];<br> $c[$j] = $t;<br> }<br> return true;<br> }<br> $i--;<br> }<br><br> for ($i = 0, $j=$s-1; $i {<br> $t = $c[$i];<br> $c[$i] = $c[$j];<br> $c[$j] = $t;<br> }<br> return false;<br>}<br>?><br><br><br> <title>排列-字典法</title><br><br><br>
当前元素: echo $data; ?>
序号 | 排列 |
---|---|
echo $num; ?> | echo implode (" ", $a); ?> |