(PHP implementation) only use ++ operations to implement addition, subtraction, multiplication, division _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
(Implemented in PHP) only the ++ operation is used to implement addition, subtraction, multiplication, and division. The code for adding and copying the code is as follows: functionjiafa ($ a, $ B) {for ($ i0; $ I $ B; $ I ++) {$ a ++ ;} return $ a;} echojiafa (); the code for copying by subtraction is as follows: functionjianfa ($ a, $ B) {$ Addition

The code is as follows:


Function jiafa ($ a, $ B)
{
For ($ I = 0; $ I <$ B; $ I ++)
{
$ A ++;
}
Return $;
}
// Echo jiafa (4, 2 );


Subtraction

The code is as follows:


Function jianfa ($ a, $ B)
{
$ C = 0;
While ($ B! = $)
{
$ B ++;
$ C ++;
}
Echo $ c;
} // End func
// Jianfa (10, 3 );


Multiplication

The code is as follows:


Function chengfa ($ a, $ B)
{
$ C = 0;
For ($ j = 0; $ j <$ B; $ j ++)
{
$ C = jiafa ($ c, $ );
}
Return $ c;
} // End func
// Chengfa (9, 3 );


Division

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 );


The pipeline code is as follows: function jiafa ($ a, $ B) {for ($ I = 0; $ I $ B; $ I ++) {$ a ++ ;} return $ a;} // echo jiafa (); the subtraction code is as follows: function jianfa ($ a, $ B) {$...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.