唯一随机数 [英] Unique Random Numbers

查看:133
本文介绍了唯一随机数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有些人可以使用简单的唯一随机数发布代码。


存储在arr [20]中的随机数但是唯一的。

解决方案

2007-03-25 16:31,Xoomer写道:





有些人可以使用简单的独特随机数发布代码。


存储在arr中的随机数[20]但独一无二。



从头到尾:


#include< cstdlib>

#包括< ctime>


int main()

{

srand(time(0));

int arr [20];


for(int i = 0; i< 20; ++ i)

arr [i] = rand();


返回0;

}


-

Erik Wikstr?m


3月25日下午3:53,Erik Wikstr?m< Erik-wikst ... @ telia.comwrote:


在2007-03-25 16:31,Xoomer写道:




有些人可以使用simpleUniqueRandomNumbers发布代码。


随机数字存储在arr [20] butunique中。



从头到尾:


#include< cstdlib>

#包括< ctime>


int main()

{

srand(time(0));

int arr [20];


for(int i = 0; i< 20; ++ i)

arr [i] = rand();


返回0;


}


-

Erik Wikstr?m



谢谢。但这个数字可能重复相同..它不是唯一的。


3月25日下午3:53,Erik Wikstr?m< Erik-wikst ... @ telia.comwrote:


2007-03-25 16:31,Xoomer写道:


您好,


有些人可以使用simpleUniqueRandomNumbers发布代码。


随机数字存储在arr [20] butunique中。



从头到尾:


#include< cstdlib>

#包括< ctime>


int main()

{

srand(time(0));

int arr [20];


for(int i = 0; i< 20; ++ i)

arr [i] = rand();


返回0;


}


-

Erik Wikstr?m



谢谢。但随机数可能重复相同..它不是唯一的。


Hi,

Can some post a code with simple Unique Random Numbers.

Random numbers stored in arr[20] but unique.

解决方案

On 2007-03-25 16:31, Xoomer wrote:

Hi,

Can some post a code with simple Unique Random Numbers.

Random numbers stored in arr[20] but unique.

From the top of my head:

#include <cstdlib>
#include <ctime>

int main()
{
srand(time(0));
int arr[20];

for (int i = 0; i < 20; ++i)
arr[i] = rand();

return 0;
}

--
Erik Wikstr?m


On Mar 25, 3:53 pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

On 2007-03-25 16:31, Xoomer wrote:

Hi,

Can some post a code with simpleUniqueRandomNumbers.

Randomnumbersstored in arr[20] butunique.


From the top of my head:

#include <cstdlib>
#include <ctime>

int main()
{
srand(time(0));
int arr[20];

for (int i = 0; i < 20; ++i)
arr[i] = rand();

return 0;

}

--
Erik Wikstr?m

Thanks. But the number may repeat the same.. its not Unique.


On Mar 25, 3:53 pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:

On 2007-03-25 16:31, Xoomer wrote:

Hi,

Can some post a code with simpleUniqueRandomNumbers.

Randomnumbersstored in arr[20] butunique.


From the top of my head:

#include <cstdlib>
#include <ctime>

int main()
{
srand(time(0));
int arr[20];

for (int i = 0; i < 20; ++i)
arr[i] = rand();

return 0;

}

--
Erik Wikstr?m

Thanks. But the random number may repeat the same.. its not Unique.


这篇关于唯一随机数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆