1 数独求解程序 php版 2 3 <?php 4 class Sudoku { 5 var $matrix; 6 7 function __construct($arr = null) { 8 if ($arr == null) { 9 $this->clear(); 10 } else { 11 $this->matrix = $arr; 12 } 13 } 14 15 function clear() { 16 for($i=0; $i<9; $i++) { 17 for($j=0; $j<9; $j++) { 18 $this->matrix[$i][$j] = array(); 19 for ($k = 1; $k <= 9; $k++) { 20 $this->matrix[$i][$j][$k] = $k; 21 } 22 } 23 } 24 } 25 26 function setCell($row, $col, $value){ 27 $this->matrix[$row][$col] = array($value => $value); 28 //row 29 for($i = 0; $i < 9; $i++){ 30 if($i != $col){ 31 if(! $this->removeValue($row, $i, $value)) { 32 return false; 33 } 34 } 35 } 36 //col 37 <
数独求解程序 php版
于 2017-07-03 15:59:14 首次发布

最低0.47元/天 解锁文章
124

被折叠的 条评论
为什么被折叠?



