作者blestadsl (咖哩桔子)
看板C_Sharp
标题Re: [问题] 棍 快被搞疯了 Random问题
时间Sun Jun 24 11:07:35 2007
....
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)