Home >Backend Development >PHP Tutorial >用php数目字九宫格

用php数目字九宫格

WBOY
WBOYOriginal
2016-06-13 11:54:161288browse

用php数字九宫格.
如下,效果:
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9 
------解决方案--------------------

$arr1 = array('1','2','3','4','5','6','7','8','9');<br />for($i=0;$i<count($arr1);$i++){<br />	array_push($arr1,array_shift($arr1));<br />	echo join(' ',$arr1)."<br />";<br />}

------解决方案--------------------

引用:
$arr1 = array('1','2','3','4','5','6','7','8','9');<br />for($i=0;$i<count($arr1);$i++){<br />	array_push($arr1,array_shift($arr1));<br />	echo join(' ',$arr1)."<br />";<br />}


上一条发错了,不好意思。
------解决方案--------------------
<br /><?php<br />for($i=0; $i<81; $i++){<br />	$tmp = $i%9+floor($i/9)+2;<br />	if($tmp>=10){<br />		$tmp = $tmp%10+1;<br />	}<br />	printf("%3d", $tmp);<br />	if(($i+1)%9==0){<br />		echo '<br>';<br />	}<br />}<br />?><br />

------解决方案--------------------
你这是什么?
九宫格是3x3矩阵(填写1-9个数)
数独是9个九宫格的组合
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