【发布时间】:2013-12-01 23:37:58
【问题描述】:
while(MatriceLib.compteTrue(champsMine)!= nbMines)
{
int i = (int) Math.floor((Math.random()*(longueur-1)));
int j = (int)Math.floor((Math.random()*(largeur-1)));
champsMine[i][j] = true;
}
champsMine 是布尔矩阵,布尔值位于随机位置。 compteTrue 正在返回矩阵中 true 数量的 int 值。 nbMines 是矩阵必须具有的真数。
问题是用值填充矩阵需要很长时间。
有没有办法提高效率?
【问题讨论】:
标签: java loops random matrix boolean