PHP classic algorithm bridge crossing

不言
Release: 2023-03-23 13:20:01
Original
1637 people have browsed it

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>";
}?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!