阅读背景:

如何在随机位置填充特定数字1和0的数组?

来源:互联网 

I have an array with 8 spots to fill and 4 ones and 4 zeros to fill it with, but want the locations to be random. I am a bit stumped on how to do this without it being to redundant. Is there a simple way to do this or will I have to fill the array with either a 1 or a zero randomly then go through and check to see if it has the right number of both after the fact? My current code is along the lines of I have an array with 8 spots to fill and 4 ones




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: