当前位置: 代码迷 >> PHP >> 不知道是错哪了,好像还是死循环
  详细解决方案

不知道是错哪了,好像还是死循环

热度:95   发布时间:2016-04-29 00:34:33.0
不知道是哪里错了,好像还是死循环
<?php
PHP code
result();function result(){    while($_POST["m"]&&$_POST["n"])    {$outmap = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);$arr[20]=array(0);$j=0;do{    for($t=0;$t<$_POST["n"];++$t)    {        $array=array($arr[$t]);        echo $outmap[$array];    }    echo "\n";    $j++;    echo $j;}while(combinatorics($arr,$_POST["m"],$_POST["n"]));}}function combinatorics($arr,$nMaxElm,$nDepth){    $n=$nDepth-1;    for(++$arr[$n];$n>=0&& $arr[$n]>=$nMaxElm;++$arr[--$n]);    if($n<0)    return 0;    for($t=$n+1;$t<$nDepth;++$t)    $arr[$t] = $arr[$n];        return 1;}?>


------解决方案--------------------
估计楼主把while($_POST["m"]&amp;&amp;$_POST["n"])
改成if($_POST["m"]&amp;&amp;$_POST["n"])你的程序会给你输出你想要的结果。



探讨
<?php

PHP code

result();
function result()
{
while($_POST["m"]&amp;&amp;$_POST["n"])
{
$outmap = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$arr[20]=array(0);
$j=0;
do{
for……

------解决方案--------------------
PHP code
while($_POST["m"]&&$_POST["n"])
  相关解决方案