Random slot algorithm

后端 未结 4 1512
执念已碎
执念已碎 2020-11-27 08:35

I have two dimensional array. I want to pick a slot at random, and continue to do so never picking the same slot twice until I have finally picked all slots (so nothing ran

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 08:54

    I did this for numbers

    list PastList=new PastList();
    private void Choоse()
    {
       int i = Recurs();
       PastList.Add(i);
    }
    
    private int Recurs()
    {
       int i;
    
       i = rnd.Next(0, 99);
       if (PastList.Contains(i))
       {
           i = Recurs();
       }
    
       return i;
    }
    

提交回复
热议问题