Home > Backend Development > PHP Tutorial > 10人喝酒隔两个人开始喝酒直到每个人都有喝过为止,输出喝酒的顺序

10人喝酒隔两个人开始喝酒直到每个人都有喝过为止,输出喝酒的顺序

WBOY
Release: 2016-06-23 14:17:52
Original
1116 people have browsed it

10人喝酒隔两个人开始喝酒直到每个人都有喝过为止,输出喝酒的顺序


回复讨论(解决方案)

$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 ."<br/>";}
Copy after login


1
4
7
10
3
6
9
2
5
8

$n = 10;$i = 0;while($n--) {  echo "$i<br>";  $i = ($i + 3) % 10;}
Copy after login

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