Home >php教程 >php手册 >(PHP实现)只使用++运算实现加法,减法,乘法,除法

(PHP实现)只使用++运算实现加法,减法,乘法,除法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 11:44:52971browse

加法

复制代码 代码如下:


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


减法

复制代码 代码如下:


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


乘法

复制代码 代码如下:


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


除法

复制代码 代码如下:


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

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


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