Ten people drink two people start drinking until everyone has drunk, the output of the order of drinking

Source: Internet
Author: User
10 people drink two people start drinking until everyone has a drink. The order of the output of drinking
10 people drink two people start drinking until everyone has a drink. The order of the output of drinking

Share to:


------Solution--------------------


$arr = Array (' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ', ' 0 ');
For ($i =0;array_sum ($arr) <10; $i = $i +3) {
if ($i >=10) $i = $i-10;
$arr [$i] = 1;
echo $i +1. "
";
}


1
4
7
10
3
6
9
2
5
8
------Solution--------------------

$n = 10;
$i = 0;
while ($n-) {
echo "$i
";
$i = ($i + 3)% 10;
}
  • 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.