SuDoKu挑战 [英] SuDoKu challenge
问题描述
我是Visual Basic的新手,并开始使用我给出的第4版副本。我很迷恋。我喜欢编写代码,并期待在不同的代码项目中创建我自己的旋转,就像你们其他人一样。
我已经整理了一个小程序,完全击败了死亡一词SuDoKu和生成要显示的板(阵列)有困难。
到目前为止我已经这样做了:
[Dim MyNum(9,9)作为整数]
[x = 1到9]
[y = 1 ro 9]
[newZ:]
[随机]
[z = Int((9 * RND)+ 1 )]
[如果y = 1则转到getnewnum]
[w =(y - 1)到1步-1]
[如果MyNum(x,y)= MyNum(x,w)然后转到newZ]
[下一个w]
[如果x = 1然后转到getnewnum]
[对于v =(x - 1)到1步-1]
[如果MyNum(x,y)= MyNum(v, y)然后转到newZ]
[下一个v]
[getnewnum]
[下一个,x]
我做过家庭作业网页作者提出的建议。我看到很多帖子都是为有经验的程序员编写的,但对我来说都没有。有没有人知道如何帮助我甚至想尝试?
我将不胜感激。
I am totally new to Visual Basic and started out with a copy of version 4 that I was given. I am hooked. I enjoy writing code and am looking forward to creating my own spins on different code projects just like the rest of you.
I have put together a small program for the totally beat-to-death term SuDoKu and am having trouble with generating the boards (arrays) to display.
I have did this thus far:
[Dim MyNum(9,9) As Integer]
[ for x = 1 to 9 ]
[ for y = 1 ro 9 ]
[newZ:]
[Randomize]
[z = Int( ( 9 * RND) + 1)]
[if y = 1 then goto getnewnum]
[ for w = ( y - 1) to 1 Step -1]
[ if MyNum(x , y) = MyNum(x , w) then goto newZ]
[ next w]
[if x = 1 then goto getnewnum]
[ for v = (x - 1) to 1 Step -1]
[ if MyNum(x , y) = MyNum(v , y) then goto newZ]
[ next v]
[getnewnum]
[next y, x]
I have done the "homework" suggested by the web page authors. There are many posts that I see that are written for you more experienced programmers, but none for me. Does anyone have a clue how to assist me or even want to try?
I would appreciate some assistance.
推荐答案
这可能是帮助:
随机填充阵列
我有alreaady看过这个帖子,这似乎让人感到困惑。我不希望将数组中的任何数字转换为1的1。另外,在我发布原始帖子之前尝试使用我的3 x 3数组和垂直数组(列)中的重复项代码。
似乎没人走过第一排。只有SuDoKu书籍制作者才有能力做到这一点吗?我猜想VB4足够强大,可以完成这项任务,但我完全愿意承认我错了,因为我是新手。
困惑! !!!!!!!!!!
I have alreaady viewed that post and it seemed way to confusing. I did not wish to convert any of the numbers in the arrays to just "1''s" and "2''s".
Additionally, trying the code before I made my original post left me with duplicates in my 3 x 3 arrays and in my vertical arrays (columns).
No one seems to go past the first row. Do only SuDoKu book makers have the ability to do this? I would guess that VB4 is powerful enough to handle this task,
but fully willing to admit that I could be wrong because I am new.
Confused!!!!!!!!!!!
我有alreaady看过这篇帖子,这似乎让人感到困惑。我不希望将数组中的任何数字转换为1的1。另外,在我发布原始帖子之前尝试使用我的3 x 3数组和垂直数组(列)中的重复项代码。
似乎没人走过第一排。只有SuDoKu书籍制作者才有能力做到这一点吗?我猜想VB4足够强大,可以完成这项任务,但我完全愿意承认我错了,因为我是新手。
困惑! !!!!!!!!!!
I have alreaady viewed that post and it seemed way to confusing. I did not wish to convert any of the numbers in the arrays to just "1''s" and "2''s".
Additionally, trying the code before I made my original post left me with duplicates in my 3 x 3 arrays and in my vertical arrays (columns).
No one seems to go past the first row. Do only SuDoKu book makers have the ability to do this? I would guess that VB4 is powerful enough to handle this task,
but fully willing to admit that I could be wrong because I am new.
Confused!!!!!!!!!!!
查看las选项,在这种情况下,对于数独,只考虑3x3方格,开始生成第1,第4和第7行:
123456789
234567891
345678912
然后是第2,第5和第8,最后是第3,第6和第9,将是这样的:
123456789
456789123
879123456
234567891
567891234
891235467
345678912
678912345
912345678
然后只是随机更改列和行,但请确保您只更改列
1与2或3,
4 5或6,
7,8或9和行相同..
你也可以改变3列和3行的集合
这是一个随机的次数,你会有一个不错的数独板
Check out the las option, in this case, for the sudoku, only consider the 3x3 squares, start generating the 1st, 4th and 7th row:
123456789
234567891
345678912
then the 2nd, 5th and 8th, and finaly the 3rd, 6th and 9th, will be something like:
123456789
456789123
879123456
234567891
567891234
891235467
345678912
678912345
912345678
Then just randomly change columns and rows, but be sure that you''ll only change column
1 with 2 or 3,
4 with 5 or 6,
7 with 8 or 9 and the same for rows..
you can also change sets of 3 columns and sets of 3 rows
do this a random number of times and you''ll have a nice sudoku board
这篇关于SuDoKu挑战的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!