标签:
Random r = new Random();
string x, y;
int a = r.Next(0,3);
int b = r.Next(0, 3);
switch(a)
{
case 0:
x="剪刀";
break;
case 1:
x="石头";
break;
case 2:
x="布";
break;
default:
x="OY";
break;
}
switch (b)
{
case 0:
y = "剪刀";
break;
case 1:
y = "石头";
break;
case 2:
y = "布";
break;
default:
y="OY";
break;
}
Console.WriteLine("x出的是"+x);
Console.WriteLine("y出的是"+y);
if (a==b)
{ Console.WriteLine("平局"); }
else if (a > b)
{ if (a == 2 && b == 0)
{ Console.WriteLine("y胜利"); }
else
{ Console.WriteLine("x胜利"); }
}
else if (b > a)
{
if (a == 0 && b == 2)
{ Console.WriteLine("x胜利"); }
else
{ Console.WriteLine("y胜利"); } }
标签:
原文地址:http://www.cnblogs.com/shitouge/p/4307556.html