猜拳练习
namespace ConsoleApplication13
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i < 3; i++)
{
Random r = new Random();
int s = r.Next(3);
Console.WriteLine("0-包袱,1-剪刀,2-錘頭");
?
Console.WriteLine("請輸入一個數:");
int c = int.Parse(Console.ReadLine());
?
if (s == 0)
{
Console.WriteLine("電腦出包袱");
}
else if (s == 1)
{
Console.WriteLine("電腦出剪刀");
}
else if (s == 2)
{
Console.WriteLine("電腦出錘頭");
}
if ((c == 0 && s == 0) || (c == 1 && s == 1) || (c == 2 && s == 2))
{
Console.WriteLine("平局");
}
if ((c == 0 && s == 2) || (c == 1 && s == 0) || (c == 2 && s == 1))
{
Console.WriteLine("你贏了");
}
else if ((c == 0 && s == 1) || (c == 1 && s == 2) || (c == 2 && s == 0))
{
Console.WriteLine("電腦贏了");
}
?
else
{
Console.WriteLine("請輸入正確的數字");
}
}
Console.ReadLine();
}
}
}
轉載于:https://www.cnblogs.com/weiwenxin01/p/5342654.html
總結
- 上一篇: 【贪心】【codeforces】651A
- 下一篇: 【map】【HDOJ】5233 Gunn