用C# 做个猜拳游戏,请问如何,才可以使这个游戏5局3胜?
Randomszl=newRandom();inti;for(i=1;i<=5;i++){Console.Write("请出拳,0是拳头,1是剪刀,3是布:");intp...
Random szl = new Random();
int i;
for (i = 1; i <= 5; i++)
{
Console.Write("请出拳,0是拳头,1是剪刀,3是布:");
int player = Convert.ToInt32(Console.ReadLine());
int com = szl.Next(0, 2);
if (player > com)
{
//玩家赢
Console.WriteLine("玩家赢!!");
}
else if (player < com)
{
//电脑赢
Console.WriteLine("电脑赢!!");
}
else
{
//平局
Console.WriteLine("平局!!");
}
}
Console.ReadKey(); 展开
int i;
for (i = 1; i <= 5; i++)
{
Console.Write("请出拳,0是拳头,1是剪刀,3是布:");
int player = Convert.ToInt32(Console.ReadLine());
int com = szl.Next(0, 2);
if (player > com)
{
//玩家赢
Console.WriteLine("玩家赢!!");
}
else if (player < com)
{
//电脑赢
Console.WriteLine("电脑赢!!");
}
else
{
//平局
Console.WriteLine("平局!!");
}
}
Console.ReadKey(); 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询