|
using System;
class ThrowRoll
{
public static void Main()
{
int roll = 0;
Random rnd = new Random(); //请高手帮我解释一下Random是什么意思或者说用法?我已知的是这句创建一个存储随机数的变量
roll=(int) rnd.Next(1,7);
Console.WriteLine("开始掷骰子");
Console.WriteLine("这次掷的骰子是:{0}",roll);
switch (roll)
{
case 1:
case 3:
case 5:
Console.WriteLine("骰子是奇数"); break;
case 2:
case 4:
case 6:
Console.WriteLine("骰子是偶数"); break;
default:
Console.WriteLine("骰子不在1~6"); break;
}
}
} |
|