4列20行6个数字怎么随机排列,保证横向不会重复? python随机生成数字不重复
excel中指定6个选项随机选4个不重复排列
比如第1行是表头,原颜色数据在A2:A7,现希望在B2:B4显示这些不重复的排列,可在B2输入公式:
=INDEX(A:A,SMALL(IF(COUNTIF(B$1:B1,A$2:A$7),"",ROW($2:$7)),INT(RAND()*(6-ROW(A1))+2)))
摁SHIFT+CTRL+回车结束公式的输入,再将公式向下拉填充复制就可以了。
excel6个数随机组合,不重复。
在a1-a6 输入 =RANDBETWEEN(1,6)
在目标单元格输入 =CONCATENATE(A1," ",A2," ",A3," ",A4," ",A5," ",A6)
按F9使目标单元格随机得出你想要的6个数为止
如何用VB做一个4行6列的随机不重复数字
'你是指每行每列的数字不重复吗?
Private Sub Command1_Click()
Me.Cls
Dim i As Integer, j As Integer, k As Integer, n As Integer
Dim a(1 To 4, 1 To 6) As Integer
Randomize
For i = 1 To 4
For j = 1 To 6
100: n = Rnd * 9 + 1
For k = 1 To 4
If n = a(k, j) Then GoTo 100
Next k
For k = 1 To 6
If n = a(i, k) Then GoTo 100
Next k
a(i, j) = n
Next j
Next i
For i = 1 To 4
For j = 1 To 6
Print a(i, j) - 1;'生成的数字是1-10,需要都减1
Next j
Next i
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
End Sub
怎么生成6位不重复的随机数
------解决方案--------------------------------------------------------不是都说了将曾经生成过的6位数放入HashSet中,随机生成一个数时先判断这个Set中是否存在,如果存在重新再生成一个新的随机数
Java code Set set = new HashSet(); Random rand = new Random(); for(int i = 0; i < 10000; i++) while(!set.add(rand.nextInt(900000) + 100000));
------解决方案-------------------------------------------------------- public void general2(){
List list = new ArrayList();
Random random = new Random();
while (true) {
int randomNum = random.nextInt(10);
boolean flag = false;