PHP Interview question: 50,40,30,20,1 These five coupons, the order amount is X yuan, the method realizes how many coupons

Source: Internet
Author: User
First I ruled out the amount for the whole order because the interviewer only gave 7 minutes.

MOU (99);//Call the following method here

Function MoU ($x) {

$array = array{50,40,30,20,1};

$temp = 0;

$j = $x;

for ($i =0;$<>< p=""><>

{

$temp = $temp +foor ($j/$array [$i]);

$j = $j% $array [$i];

}

echo "Altogether needs". $temp. " Coupon Roll ";

return $temp;

}

?>

This method is simple to use a bit of the mold, I hope to have a master to give me a better way, directly reply to the good

The above introduces the PHP interview question: 50,40,30,20,1 This five coupons, the order amount of X, the method to achieve the return of how many coupons, including the content, I hope the PHP tutorial interested in a friend helpful.

  • 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.