تولید N عدد تصادفی بدونه تکرار - با استفاده از HashSet
public
static
int
[] RandomNumbers(
int
n,
int
min,
int
max)
{
Random rnum =
new
Random();
HashSet<
int
> hset =
new
HashSet<
int
>();
while
(hset.Count < n)
hset.Add(rnum.Next(min,max));
int
[] OutPut = hset.ToArray();
return
OutPut;
}
+ نوشته شده در دوشنبه دهم مهر ۱۳۹۶ ساعت 10:26 توسط محسن
|