首页 > 代码库 > 数独助手
数独助手
<script type="text/javascript">// > (v%3);}Pos.prototype.checkFix = function(){ var count = 0; var pos=-1; var i; for(i=0; i<3; i++) { if(this.pbit[i]!=0) { count ++; pos = i; } } if(count == 0) { alert("invalid " + this.x + " " + this.y); return 0; } if(count>1) return 0; if(this.pbit[pos] == 4 || this.pbit[pos] == 2 || this.pbit[pos] == 1) { this.fixValue = http://www.mamicode.com/pos*3 + (this.pbit[pos]==4?0:(this.pbit[pos]==2?1:2)) + 1;>> (v%3)); return this.checkFix();}Pos.prototype.text = function(line, col){ if(this.pbit[line] & (4 >> col)) { var v = (line*3 + col + 1).toString();; return ""; td += v; td += " "; return td;}Pos.prototype.draw = function(){ var html = "";; html += ""; for(i=0; i<9; i++) { html += "
"; this.obj.innerHTML = html;}function setValue(x, y, v){ var newFixCount = 0; r.setValue(x, y, v); newFixCount = r.unsetValue(x, y, v); while(newFixCount>0) { newFixCount = 0; var i, j; for(i=0; i<9; i++) for(j=0; j<9; j++) { if(r.isNewFix(i,j)) newFixCount += r.unsetValue(i, j, r.value(i,j)); } }}var xStack = [];var yStack = [];var vStack = [];function clickValue(x, y, v){ xStack.push(x); yStack.push(y); vStack.push(v); setValue(x, y, v); r.draw();}function undoClick(){ r.clear(); xStack.pop(); yStack.pop(); vStack.pop(); var i; for(i=0; i</script><style></style>
" + v + "
"; } return "";}Pos.prototype.drawTd = function(v){ var td = ""; td += ""; if(this.fixValue) { var tableClass = "fix"; if(this.error) tableClass = "err"; html += ""; html += "
"; } else { html += ""; for(i=0; i<3; i++) { html += "
"; } html += "
" return html;}function Rect9(obj){ this.obj = obj; this.p = []; var i; var j; for(i=0; i< 9; i++) { this.p[i] = new Array(); for(j=0; j< 9; j++) { this.p[i][j] = new Pos(i, j); } }}Rect9.prototype.clear = function(){ var i; var j; for(i=0; i< 9; i++) { for(j=0; j< 9; j++) { this.p[i][j].clear(); } }}Rect9.prototype.value = http://www.mamicode.com/function(x, y)""; html += this.p[i][j].draw(); html += " | "; } html += "
<script type="text/javascript">// </script>
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。