递归函数自己调用自己
作者:
孤岛渔夫 | 来源:发表于
2016-12-04 01:38 被阅读0次 <?php
// recursive 递归
// 递归函数: 函数自己调用自己
/*
$a = 30;
30
20
10
0
---------------
0
10
20
30
*/
$a = 30;
echo $a.'<br>';
if(30 > 0){
echo 20;
echo '<br>';
if(20>0){
echo 10;
echo '<br>';
if(10>0){
echo 0;
echo '<br>';
if(0>0){
}else{
echo '------------------<br>';
}
echo 0;
echo '<br>';
}
echo 10;
echo '<br>';
}
echo 20;
echo '<br>';
}
echo $a.'<br>';
echo '<hr>';
// 递归函数
function recursive1($n){
echo $n.'<br>';
if($n > 0){
recursive1($n-10);
}else{
echo '---------------<br>';
}
echo $n.'<br>';
}
recursive1(30);
echo '<hr>';
recursive1(100);
?>
本文标题:递归函数自己调用自己
本文链接:https://www.haomeiwen.com/subject/akfhmttx.html
网友评论