您的位置:首页 > 其它

猜拳三局两胜

2015-06-18 15:54 120 查看
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int rcount = 0;
int dncount = 0;
for (int i = 0; i < 3; i++)
{
Console.Write("请输入(0 || 1 || 2分别代表剪刀||锤|| 布):");
int a = int.Parse(Console.ReadLine());
Random r = new Random();
int PC = r.Next(3);
if (a >= 0 && a < 3)
{
if (PC - a == -1 || PC - a == 2)
{
Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a+"赢了");//赢了
rcount++;

}
else if (PC == a )
{
Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a);
i = i - 1;

}
else
{
Console.WriteLine("电脑出拳{0},你出拳{1}", PC, a+"输了");
dncount++;
}
}

else
{
Console.WriteLine("请输入正确的数字!");
i = i - 1;
}
}
if (rcount == 2)
{
Console.WriteLine("三局两胜,恭喜,你赢了!");
}
else if (dncount == 2)
{
Console.WriteLine("三局两胜,你输了!");
}

Console.ReadLine();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: