您的位置:首页 > 其它

猜拳

2015-06-18 15:41 323 查看
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)
{
while (true)
{

Console.Write("请输入(0 || 1 || 2分别代表剪刀||锤|| 布):");

int a = int.Parse(Console.ReadLine());
Random r = new Random();
int PC = r.Next(3);
Console.WriteLine("电脑为{0}", PC);
if (a < 0 || a >= 3)
{
Console.WriteLine("请输入正确的数字!");
}
else if (a == 2 &&PC ==0)
{
Console.WriteLine("你输了,真遗憾!");
}
else if (PC == 2 && a == 0)
{
Console.WriteLine("你赢了,好棒!");
}
else
{

if (a == PC)
{
Console.WriteLine("打平了,请继续努力!");
}
else if (a > PC)
{
Console.WriteLine("你赢了,好棒!");
}

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