pascal sudoku problem
以下是一個數獨的題目
‘0’代表空白(space)
0 0 1 0 0 5 0 0 0
0 7 0 0 0 0 6 9 0
0 6 5 7 0 4 3 0 2
5 0 6 0 3 0 7 0 0
0 0 0 6 1 9 0 0 0
0 0 2 0 4 0 9 0 3
7 0 4 8 0 3 1 5 0
1 3 0 0 0 0 0 7 0
0 0 0 1 0 0 2 0 0
請問各位高手如何才能使用方位鍵(上下左右)移動去輸入1 to 9 的integer
問題是當方格内的數字不是‘0’,(即使1至9的integer),
方位鍵就可以直接跳過該數去旁邊有0(space)的地方
e.g. 第一橫行,當方位鍵在第二個格内,方位鍵就可以直接跳過’1‘(第三個格)到第四個格(‘0’)....
而避免overlap
那麽
如何才可寫成這段code?????
2006-08-08 12:33:35 · 2 個解答 · 發問者 Anonymous in 電腦與網際網路 ➔ 軟體
記住!
是用pascal program 哦!
2006-08-09 12:34:54 · update #1
使用vba,程式如下:數獨工作表:Private Sub Worksheet_SelectionChange(ByVal Target As Range)If Target.Column < 10 And Target.Row < 10 Then Application.OnKey "{LEFT}", "sleft" Application.OnKey "{RIGHT}", "sright" Application.OnKey "{down}", "sdown" Application.OnKey "{up}", "sup"Else Application.OnKey "{LEFT}" Application.OnKey "{RIGHT}" Application.OnKey "{down}" Application.OnKey "{up}"End IfEnd Sub插入模組:Sub sleft()Dim Cn As Integer, Rw As IntegerCn = ActiveCell.ColumnRw = ActiveCell.RowDo Until Cn = 0 Cells(Rw, Cn).Select If Cells(Rw, Cn) = "" Then Exit Sub Cn = Cn - 1LoopEnd SubSub sright()Dim Cn As Integer, Rw As IntegerCn = ActiveCell.ColumnRw = ActiveCell.RowDo Until Cn = 10 Cells(Rw, Cn).Select If Cells(Rw, Cn) = "" Then Exit Sub Cn = Cn + 1LoopEnd SubSub sup()Dim Cn As Integer, Rw As IntegerCn = ActiveCell.ColumnRw = ActiveCell.RowDo Until Rw = 0 Cells(Rw, Cn).Select If Cells(Rw, Cn) = "" Then Exit Sub Rw = Rw - 1LoopEnd SubSub sdown()Dim Cn As Integer, Rw As IntegerCn = ActiveCell.ColumnRw = ActiveCell.RowDo Until Rw = 10 Cells(Rw, Cn).Select If Cells(Rw, Cn) = "" Then Exit Sub Rw = Rw + 1LoopEnd SubSub auto_open() Application.OnKey "{LEFT}" Application.OnKey "{RIGHT}" Application.OnKey "{down}" Application.OnKey "{up}"End Sub有一小缺點,若空格沒輸入數字就不能用方向鍵移動,只能用滑鼠點選.若需要檔案,請告知信箱.
2006-08-08 19:24:56 補充:
注意看你的題目發現,我好像誤會了,你不是用excel吧?
2006-08-08 15:17:17 · answer #1 · answered by 牛仔褲1431 6 · 0⤊ 0⤋
3 4 1 9 8 5 4 8 7
2 7 8 3 2 1 6 9 5
9 6 5 7 8 4 3 1 2
5 9 6 2 3 8 7 4 1
4 7 3 6 1 9 5 2 8
8 1 2 5 4 7 9 6 3
7 2 4 8 9 3 1 5 6
1 3 6 4 5 2 8 7 9
9 5 8 1 7 6 2 3 4
2006-08-17 11:19:41 · answer #2 · answered by 魆魆 3 · 0⤊ 0⤋