Re: [問題] 棍 快被搞瘋了 Random問題

看板C_Sharp (C#)作者 (咖哩桔子)時間18年前 (2007/06/24 11:07), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/4 (看更多)
.... public test1() { index = new int[6]; Random r ; for (int i = 0; i < index.Length; i++) { r = new Random(unchecked((int)DateTime.Now.Ticks) + i); index[i] = r.Next() % 2; } } ... 沒測試過...試試看吧! ※ 引述《reptile0426 ( )》之銘言: : 補上程式碼 : class test1 : { : public int [] index; : public test1() : { : index = new int[6]; : Random r = new Random(unchecked((int)DateTime.Now.Ticks)); : for (int i = 0; i < index.Length; i++) : index[i] = r.Next(1000000000) % 2; : //index[i] = r.Next(2); : } : } : static void Main(string[] args) : { : test1 xxxxx = new test1(); : test1 xxx = new test1(); : test1 xxxx = new test1(); : } : } : 我只要亂數取 0 OR 1 : 取出來index[]的RANDOM數 都一樣 大家幫幫忙吧 : 註解哪一行也一樣 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.126.21.8 ※ 編輯: blestadsl 來自: 140.126.21.8 (06/24 11:09)
文章代碼(AID): #16VT_vPC (C_Sharp)
文章代碼(AID): #16VT_vPC (C_Sharp)