第1个回答 推荐于2018-04-07
Random r = new Random();
Dictionary<int, int> dic = new Dictionary<int, int>();
while (dic.Count + 1 < 6)
{
int tmp = r.Next(0, 50);
if (!dic.ContainsKey(tmp))
dic.Add(tmp, 0);
}
这个不是正态随机本回答被网友采纳
第2个回答 推荐于2016-11-27
Random r = new Random();
Dictionary<int, byte> dic = new Dictionary<int, byte>();
while (dic.Count + 1 < 5)
{
int tmp = r.Next(0, 50);
if (!dic.ContainsKey(tmp))
dic.Add(tmp, 0);
}本回答被提问者采纳