Home >Backend Development >PHP Tutorial >PHP classic algorithm bridge crossing

PHP classic algorithm bridge crossing

不言
不言Original
2018-04-10 10:04:051686browse

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 &#39;第&#39;.$count.&#39;次过桥,剩下[&#39;.$i.&#39;]&#39;."</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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn