Re: [問題] 棍 快被搞瘋了 Random問題
....
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)
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 3 之 4 篇):
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章