在方格中填入1,2,3,4,5,6,7,8,9使得算式成立(数字不得重复)□□□□*□=□□□□
在方格中填入1,2,3,4,5,6,7,8,9使得算式成立(数字不得重复)□□□□*□=□□□□
1738× 4 = 6952
1963 × 4 = 7852
运行以下的VB代马可得出结果:
Dim a As Long
Dim b As Long
Dim c1,c2,c3,c4,c5,c6,c7,c8,c9 As Integer
For c1 = 1 To 9
For c2 = 1 To 9
For c3 = 1 To 9
For c4 = 1 To 9
For c5 = 1 To 9
For c6 = 1 To 9
For c7 = 1 To 9
For c8 = 1 To 9
c9 = 45 - c1 - c2 - c3 - c4 - c5 - c6 - c7 - c8
If c1 = c2 Or c1 = c3 Or c1 = c4 Or c1 = c5 Or c1 = c6 Or c1 = c7 Or c1 = c8 Or c1 = c9 Then GoTo aa
If c2 = c3 Or c2 = c4 Or c2 = c5 Or c2 = c6 Or c2 = c7 Or c2 = c8 Or c2 = c9 Then GoTo aa
If c3 = c4 Or c3 = c5 Or c3 = c6 Or c3 = c7 Or c3 = c8 Or c3 = c9 Then GoTo aa
If c4 = c5 Or c4 = c6 Or c4 = c7 Or c4 = c8 Or c4 = c9 Then GoTo aa
If c5 = c6 Or c5 = c7 Or c5 = c8 Or c5 = c9 Then GoTo aa
If c6 = c7 Or c6 = c8 Or c6 = c9 Then GoTo aa
If c7 = c8 Or c7 = c9 Then GoTo aa
If c8 = c9 Then GoTo aa
a = c1 * 1000 + c2 * 100 + c3 * 10 + c4
b = c6 * 1000 + c7 * 100 + c8 * 10 + c9
If a * c5 = b Then MsgBox CStr(a) & "*" & CStr(c5) & "=" & CStr(b)
aa:
Next c8,c7,c6,c5,c4,c3,c2,c1