C#掷股子(Random的应用)

来源:互联网 发布:windows to go 什么用 编辑:程序博客网 时间:2024/05/16 18:16
//MaxFiner.csusing System;namespace HelloWorld{    class MaxFinder    {        static void Main()        {            Random rNum = new Random();            int rValue;            //掷20次股子            for (int i = 1; i <= 20; i++)            {                rValue = rNum.Next(1, 7);                Console.Write("{0} ",rValue);                if (i % 5 == 0)     //每5个数一行                    Console.WriteLine();            }        }    }   }