帮助数组和随机 [英] Help with Arrays and Random
问题描述
我是JAVA语言的初学者...
我正在制作一个简单的数独游戏(在记事本中 - 我只能使用记事本)。
我把我的数独表存储在2d数组中,例如sudoku1 [9] [9]。
假设我有5个2d阵列,数独1 ......数独,我想要一个随机的数组选择......我该怎么做。
我知道我必须使用Random类,但在这种情况下如何制作它(即2d数组)??
>
还
这就是你把价值放在二维数组中的方式......
int [] [] example2d =
{
{0,3,2},
{0,5,8},
};
如何将值放入3d数组?
int [] [] [] example3d =
???????
Hi, I am a beginner in JAVA language...
I am making a simple sudoku game (in notepad -I have to use only notepad).
I have my sudoku tables stored in 2d arrays e.g sudoku1[9][9].
Lets say I have 5 2d-arrays, sudoku1....sudoku5, and I want a random one to be chosen... how do I do that.
I know I have to use class Random, but how do I make it in this case (i.e 2d arrays)??
also
this is how u put values in a 2d array...
int [][] example2d=
{
{0, 3, 2},
{0, 5, 8},
};
how can u put values in a 3d array??
int [][][] example3d=
???????
推荐答案
几个不同的文件中是否存在不同的数独值,或者是同一个文件中的所有数据?
要输入3d数组...
Are the different sudoku values in several different files, or all in the same file?
To input into a 3d array...
我是初学者,我不是通过归档来确定你的意思(我的意思是作为一个java程序员)...我把它们存储起来......
I am a beginner, I am not sure about what you mean by filing them (I mean as a java programmer)... I have them stored like this...
啊......对不起,我读错了你的问题,并认为你把数独谜题存放在一个文本文件中。继续,忽略第一行:)
是的,创建一个像这样的3D数组应该有效......我想知道你是否可以像这样初始化它:
Ahh...sorry, I had read your question wrong and thought you were storing the sudoku puzzles in a text file. Go ahead and ignore that first line :)
Yes, creating a 3d array like that should work...I wonder if you can initialize it like this:
这篇关于帮助数组和随机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!