(PHP implementation) Only use ++ operations to implement addition, subtraction, multiplication, and division_PHP tutorial

WBOY
Release: 2016-07-21 15:02:54
Original
1505 people have browsed it

Addition

Copy code The code is as follows:

function jiafa($a,$b)
{
for($i=0;$i<$b;$i++)
{
$a++;
}
return $a;
}
/ /echo jiafa(4,2);

Subtraction
Copy code The code is as follows:

function jianfa($a,$b)
{
$c=0;
while($b!=$a)
{
$b++;
$c++;
}
echo $c;
} // end func
//jianfa(10,3);

Multiplication
Copy code The code is as follows:

function chengfa($a,$b)
{
$c=0;
for($j=0;$j<$b;$j++)
{
$c=jiafa($c,$a);
}
return $c;
} // end func
//chengfa(9,3);

Division
Copy code The code is as follows:

function chufa($d,$e)
{
$k=0;
$f= 0;
while($f<$d)
{
$k++;
$f=chengfa($e,$k);

}
return $ k;
} // end func
echo chufa(16,2);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327885.htmlTechArticleAdditional copy code The code is as follows: function jiafa($a,$b) { for($i=0;$ i$b;$i++) { $a++; } return $a; } //echo jiafa(4,2); The subtraction copy code is as follows: function jianfa($a,$b) { $...
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!