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