4.27语句.剪刀石头布练习
Console.Write
int yh = Convert.ToInt32(Console.ReadLine());
Random r = new Random();
int dn = r.Next(0, 3);
//3、对比,输出结果
//石头0,剪子1,布2
//0 1 = -1
//1 2 = -1
//2 0 = 2
//0 2 = -2
//1 0 = 1
//2 1 = 1
int jg = yh - dn;
if (jg == -1 || jg == 2)
{
Console.WriteLine("用户胜利!");
}
else if (jg == -2 || jg == 1)
{
Console.WriteLine("用户失败!");
}
else
{
Console.WriteLine("平局!");
}
}
Console.ReadLine();