- ふらっと C#,C♯,C#(初心者用) Part114©2ch.net
810 :デフォルトの名無しさん[sage]:2015/03/03(火) 13:16:43.47 ID:bwxKcpFi - for (int i = 0; i < 9; i++) Console.Write("{0}", new Random(i + Environment.TickCount).Next(4).ToString());
↑これだと乱数が偏ってたり何か規則的なんですが static class RandomManager { static Random rnd = new Random(); static public int Next(int num) { return rnd.Next(num); } } for (int i = 0; i < 9; i++) Console.Write("{0}", RandomManager.Next(4).ToString()); ↑これから呼び出すとあまり偏らず規則的にもならないのですが、どういう原理ですか?
|
|