求助大佬:随机生成数字且随机排列
一、随机生成10个数,(30~35)7个,(26~29)3个,均保留一位小数;二、生成的10个数随机分布且(26~29)的3个数两两不能相邻。
样本:
33.2,29.3,32.1,30.4,34.6,(换行)
34.3,32.8,27.3,32.1,28.2
(10个数可以重复)
谢谢各位大佬! 有大神吗 直接用一个公式解决不会,用10个公式可以试一下,公式从B2至B11单元格,
可直接复制以下全部公式,选中B2单元格,Ctrl + V 粘贴
=RANDBETWEEN(26,35)+TRUNC(RAND(),1)
=IF(B2<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))+TRUNC(RAND(),1)
=IF(B3<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))+TRUNC(RAND(),1)
=IF(B4<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))+TRUNC(RAND(),1)
=IF(B5<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))+TRUNC(RAND(),1)
=IF(COUNTIF(B$2:B6,"<30")=3,RANDBETWEEN(30,35),IF(COUNTIF(B$2:B6,"<30")=0,RANDBETWEEN(26,29),IF(B6<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))))+TRUNC(RAND(),1)
=IF(COUNTIF(B$2:B7,"<30")=3,RANDBETWEEN(30,35),IF(B7<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35)))+TRUNC(RAND(),1)
=IF(COUNTIF(B$2:B8,"<30")=3,RANDBETWEEN(30,35),IF(COUNTIF(B$2:B8,"<30")=1,RANDBETWEEN(26,29),IF(B8<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35))))+TRUNC(RAND(),1)
=IF(COUNTIF(B$2:B9,"<30")=3,RANDBETWEEN(30,35),IF(B9<30,RANDBETWEEN(30,35),RANDBETWEEN(26,35)))+TRUNC(RAND(),1)
=IF(COUNTIF(B$2:B10,"<30")=3,RANDBETWEEN(30,35),RANDBETWEEN(26,29))+TRUNC(RAND(),1)
太强了!纯公式,谢谢大神! 大神,可以请教下几点吗?
如果26~29换其他、30~35换其他、3个26~29换成1个或2个,要怎么改? 大神,可以请教下几点吗?
如果26~29换其他、30~35换其他、3个26~29换成1个或2个,要怎么改? 公式中的 RANDBETWEEN(26,35)、RANDBETWEEN(26,29)、RANDBETWEEN(30,35)就是用来生成不同范围的随机数的,可以根据需要将 "<=30"改为相应的判断
最麻烦的是控制特殊值的数量,3个换成2个或者其他数,很多公式都要根据实际情况改。
你这个问题我想不到简单的办法 好的,已经可以了,谢谢大佬 大神,这公式小概率出现第5、第6个随机数为26~29,也就是相邻的情况 =MOD(SMALL(IF({0;1},RANDBETWEEN({9,9,9,9,9},99)*{-1,1,0,0,0}+{0,0,1,2,3},RANDBETWEEN(-11*{9,9,9,9,9},99))/1%%+RANDBETWEEN({3,3,3,3,3;2.6,2.6,3,2.6,3}/1%,{35,35,35,35,35;26,26,35,26,35}*10+9),{0;5}+COLUMN(A:E)),1000)/10
保险点再加个限制
=MOD(SMALL(IF({0;1},RANDBETWEEN({9,9,9,9,9},99)*{-1,1,0,0,0}+{0,0,1,2,3},-1^RANDBETWEEN({9,9,9,9,9},99)*RANDBETWEEN({9,9,9,9,9},99))/1%%+RANDBETWEEN({3,3,3,3,3;2.6,2.6,3,2.6,3}/1%,{35,35,35,35,35;26,26,35,26,35}*10+9),{0;5}+COLUMN(A:E)),1000)/10