Home >Backend Development >PHP Tutorial >PHP classic algorithm bridge crossing
The content of this article introduces the classic algorithm of PHP. I will share it with you here. Friends in need can refer to it
<?php /* 假设某人有100,000现金。 每次经过一次路口需要进行一次缴费。 身上钱大于5000,则缴费5% 身上钱小于5000,则缴费5000. 问:此人可以经过多少次这个路口? */for($i=100000,$count=0;$i>=5000;){ $count +=1; if($i>50000){ $i =$i-$i*0.05; }else{ $i -=5000; } echo '第'.$count.'次过桥,剩下['.$i.']'."</br>"; }?>
Related recommendations:
php Classic Algorithm Example Analysis
PHP Classic Algorithm Collection
##PHP Classic Method of Crawling Network Data index.php forum.php phpno
The above is the detailed content of PHP classic algorithm bridge crossing. For more information, please follow other related articles on the PHP Chinese website!