if(a <= 0) return new Geocache[0]
Random rand = new Random()
Geocache[] result = new Geocache[a]
for(int i = 0 i 模扮< a i++) {
//因为题目没有描述,这里假设x, y是随机整数,Geocache有构造函数(int, int)
int x = rand.nextInt()
int y = rand.nextInt()
result[i] = new Geocache(x, y)
}
数码漏 return result
}
我使用 VB 编镇绝铅写了一个 数独 计算器,御好其中就有一部分是 检测 数独 是否正确的。Private Sub Command9_Click() '测试 填写是否正确Dim i, j, k, m, n, bTest
Dim CeShiShuZu(9) As String
For i = 0 To 8
For j = 0 To 8
CeShiShuZu(j) = LTrim$(Str$(Val(Text2(i * 9 + j).Text)))
Next j
If Not CeShi(CeShiShuZu) Then
MsgBox "第 " &Str$(i + 1) &" 行内有重复!!"
Exit Sub
End If
Next i
For i = 0 To 8
For j = 0 To 8
CeShiShuZu(j) = LTrim$(Str$(Val(Text2(i + j * 9).Text)))
Next j
If Not CeShi(CeShiShuZu) Then
MsgBox "第 " &Str$(i + 1) &" 列内有重复!!"
Exit Sub
End If
Next i
For j = 0 To 2
For k = 0 To 2
For m = 0 To 2
For n = 0 To 2
CeShiShuZu(m + n * 3) = LTrim$(Str$(Val(Text2(fenkuai(j, m, k, n)).Text)))
Next n
Next m
If Not CeShi(CeShiShuZu) Then
MsgBox "第宏盯 " &Str$(j + k * 3) &" 列内有重复!!"
Exit Sub
End If
Next k
Next j
MsgBox "恭喜你,完全正确!!"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)